Skip to content

Commit

Permalink
Merge pull request #4466 from david-poindexter/issue-3875-dnn-react-c…
Browse files Browse the repository at this point in the history
…ommon

Migrate moment to dayjs for Dnn.React.Common
  • Loading branch information
valadas committed Feb 8, 2021
2 parents dd09285 + 63f3cc5 commit 13f7f4f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
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

0 comments on commit 13f7f4f

Please sign in to comment.