Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate moment to dayjs for Dnn.React.Common #4466

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ function formatDate(dateValue, longformat) {
return "-";
}

return Moment(dateValue).locale(utilities.getCulture()).format(longformat === true ? "LLL" : "L");
const localizedFormat = require('dayjs/plugin/localizedFormat');
dayjs.extend(localizedFormat);
return dayjs(dateValue).locale(utilities.getCulture()).format(longformat === true ? "LLL" : "L");
}
function getUserMode(){
return config.userMode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = {
"react-tooltip": "window.dnn.nodeModules.ReactTooltip",
"react-widgets": "window.dnn.nodeModules.ReactWidgets",
"throttle-debounce": "window.dnn.nodeModules.ThrottleDebounce",
/** @deprecated for v.10 - moment JS will no longer be delivered - recommended to manage own packages moving forward */
"moment": "window.dnn.nodeModules.Moment",
"es6-promise": "window.dnn.nodeModules.Es6Promise",
"@dnnsoftware/dnn-react-common": "window.dnn.nodeModules.CommonComponents"
Expand Down
4 changes: 2 additions & 2 deletions Dnn.AdminExperience/ClientSide/Dnn.React.Common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"storybook": "start-storybook -p 9001 -c .storybook"
},
"dependencies": {
"dayjs": "^1.10.4",
"interact.js": "^1.2.8",
"moment": "^2.22.2",
"raw-loader": "2.0.0",
"react-accessible-tooltip": "^2.0.3",
"react-collapse": "^4.0.3",
Expand Down Expand Up @@ -98,4 +98,4 @@
"react-dom": "^16.4.2",
"react-hot-loader": "^4.8.5"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from "react";
import PropTypes from "prop-types";
import DayPicker, { WeekdayPropTypes, DateUtils } from "react-day-picker";
import moment from "moment";
import * as dayjs from "dayjs";
import TimePicker from "./TimePicker";
import TimezonePicker from "./TimezonePicker";
import timeZones from "./timeZones";
Expand Down Expand Up @@ -250,7 +250,7 @@ class DatePicker extends Component {

formatDate(date, format = "dddd, MMMM, Do, YYYY") {
if (date) {
return moment(date).format(format);
return dayjs(date).format(format);
}
return date;
}
Expand Down