From ca1c613dbba333397a30c854931ac8a6a3e15d8a Mon Sep 17 00:00:00 2001 From: Michael An <1822852997@qq.com> Date: Sat, 24 Aug 2019 11:47:09 +0800 Subject: [PATCH 01/41] add hour and minute --- assets/index/Calendar.less | 68 ++++++++++++++++++++++++++- examples/antd-calendar.js | 10 ++-- examples/antd-month-calendar.js | 10 ++-- examples/antd-range-calendar.js | 10 ++-- examples/control-panel.js | 6 +-- examples/custom-clear-icon.js | 6 +-- examples/full-calendar.js | 8 ++-- examples/getCalendarContainer.js | 10 ++-- examples/start-end-range.js | 10 ++-- examples/start-end.js | 10 ++-- examples/week.js | 26 +++++------ package.json | 12 ++--- src/Calendar.jsx | 14 +++++- src/calendar/CalendarRightPanel.jsx | 72 +++++++++++++++++++++++++++++ 14 files changed, 211 insertions(+), 61 deletions(-) create mode 100644 src/calendar/CalendarRightPanel.jsx diff --git a/assets/index/Calendar.less b/assets/index/Calendar.less index 3a755cb28..ad26d4ffa 100644 --- a/assets/index/Calendar.less +++ b/assets/index/Calendar.less @@ -2,7 +2,7 @@ position: relative; outline: none; font-family: Arial, "Hiragino Sans GB", "Microsoft Yahei", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans-serif; - width: 253px; + width: fit-content; border: 1px solid #ccc; list-style: none; font-size: 12px; @@ -14,9 +14,15 @@ border: 1px solid #ccc; line-height: 1.5; + + &-date-panel, &-date-panel-container { + display: flex; + } + &-date-panel, &-panel { position: relative; outline: none; + display: block; } &-week-number { @@ -127,6 +133,66 @@ height: 217px; } + &-right-panel { + width: 68px; + height: inherit; + } + + &-right-panel-header { + height: 34px; + line-height: 34px; + span { + transform: rotate(-90deg); + } + } + + &-right-panel-body { + height: 217px; + border-left: 1px solid #ccc; + overflow-y: scroll; + ul { + list-style: none; + box-sizing: border-box; + margin: 0; + padding: 0; + width: 100%; + } + ul li { + text-align: center; + padding: 8px 0; + cursor: pointer; + } + ul li:hover { + color: #e8bf6a; + } + ul li.highlight { + color: #f09f3f; + } + &::-webkit-scrollbar { + width: 0; + } + } + + &-right-panel-footer { + height: 39px; + line-height: 34px; + border-left: 1px solid #ccc; + span { + transform: rotate(90deg); + } + } + + &-right-panel-header, &-right-panel-footer { + display: flex; + justify-content: center; + cursor: pointer; + color: #999; + font-size: 16px; + span:after { + content: '›'; + } + } + table { border-collapse: collapse; max-width: 100%; diff --git a/examples/antd-calendar.js b/examples/antd-calendar.js index ea2314114..af7fa46f9 100644 --- a/examples/antd-calendar.js +++ b/examples/antd-calendar.js @@ -1,13 +1,13 @@ /* eslint react/no-multi-comp:0, no-console:0 */ -import 'rc-calendar/assets/index.less'; +import '@seafile/seafile-calendar/assets/index.less'; import React from 'react'; import ReactDOM from 'react-dom'; import PropTypes from 'prop-types'; -import Calendar from 'rc-calendar'; -import DatePicker from 'rc-calendar/src/Picker'; -import zhCN from 'rc-calendar/src/locale/zh_CN'; -import enUS from 'rc-calendar/src/locale/en_US'; +import Calendar from '@seafile/seafile-calendar'; +import DatePicker from '@seafile/seafile-calendar/src/Picker'; +import zhCN from '@seafile/seafile-calendar/src/locale/zh_CN'; +import enUS from '@seafile/seafile-calendar/src/locale/en_US'; import 'rc-time-picker/assets/index.css'; import TimePickerPanel from 'rc-time-picker/lib/Panel'; diff --git a/examples/antd-month-calendar.js b/examples/antd-month-calendar.js index 15ed13f29..86f1620ec 100644 --- a/examples/antd-month-calendar.js +++ b/examples/antd-month-calendar.js @@ -1,14 +1,14 @@ /* eslint react/no-multi-comp:0, no-console:0 */ -import 'rc-calendar/assets/index.less'; +import '@seafile/seafile-calendar/assets/index.less'; import React from 'react'; import ReactDOM from 'react-dom'; import PropTypes from 'prop-types'; -import MonthCalendar from 'rc-calendar/src/MonthCalendar'; -import DatePicker from 'rc-calendar/src/Picker'; +import MonthCalendar from '@seafile/seafile-calendar/src/MonthCalendar'; +import DatePicker from '@seafile/seafile-calendar/src/Picker'; -import zhCN from 'rc-calendar/src/locale/zh_CN'; -import enUS from 'rc-calendar/src/locale/en_US'; +import zhCN from '@seafile/seafile-calendar/src/locale/zh_CN'; +import enUS from '@seafile/seafile-calendar/src/locale/en_US'; import moment from 'moment'; import 'moment/locale/zh-cn'; diff --git a/examples/antd-range-calendar.js b/examples/antd-range-calendar.js index 717d77a19..63620dfeb 100644 --- a/examples/antd-range-calendar.js +++ b/examples/antd-range-calendar.js @@ -2,12 +2,12 @@ import React from 'react'; import ReactDOM from 'react-dom'; -import Picker from 'rc-calendar/src/Picker'; -import RangeCalendar from 'rc-calendar/src/RangeCalendar'; -import zhCN from 'rc-calendar/src/locale/zh_CN'; -import enUS from 'rc-calendar/src/locale/en_US'; +import Picker from '@seafile/seafile-calendar/src/Picker'; +import RangeCalendar from '@seafile/seafile-calendar/src/RangeCalendar'; +import zhCN from '@seafile/seafile-calendar/src/locale/zh_CN'; +import enUS from '@seafile/seafile-calendar/src/locale/en_US'; import TimePickerPanel from 'rc-time-picker/lib/Panel'; -import 'rc-calendar/assets/index.less'; +import '@seafile/seafile-calendar/assets/index.less'; import 'rc-time-picker/assets/index.css'; import moment from 'moment'; diff --git a/examples/control-panel.js b/examples/control-panel.js index 0a8ac633f..a2ba16e4b 100644 --- a/examples/control-panel.js +++ b/examples/control-panel.js @@ -1,9 +1,9 @@ /* eslint react/no-multi-comp:0, no-console:0, no-unused-vars:0 */ -import 'rc-calendar/assets/index.less'; +import '@seafile/seafile-calendar/assets/index.less'; import React from 'react'; import ReactDOM from 'react-dom'; -import Calendar from 'rc-calendar/src'; -import RangeCalendar from 'rc-calendar/src/RangeCalendar'; +import Calendar from '@seafile/seafile-calendar/src'; +import RangeCalendar from '@seafile/seafile-calendar/src/RangeCalendar'; import Select, { Option } from 'rc-select'; import 'rc-select/assets/index.css'; diff --git a/examples/custom-clear-icon.js b/examples/custom-clear-icon.js index 93b8d4c36..f5f6fe71d 100644 --- a/examples/custom-clear-icon.js +++ b/examples/custom-clear-icon.js @@ -1,10 +1,10 @@ /* eslint react/no-multi-comp:0, no-console:0 */ -import 'rc-calendar/assets/index.less'; +import '@seafile/seafile-calendar/assets/index.less'; import React from 'react'; import ReactDOM from 'react-dom'; -import Calendar from 'rc-calendar'; -import RangeCalendar from 'rc-calendar/src/RangeCalendar'; +import Calendar from '@seafile/seafile-calendar'; +import RangeCalendar from '@seafile/seafile-calendar/src/RangeCalendar'; import 'rc-time-picker/assets/index.css'; import 'moment/locale/zh-cn'; diff --git a/examples/full-calendar.js b/examples/full-calendar.js index 2cf7ed64b..5936b70df 100644 --- a/examples/full-calendar.js +++ b/examples/full-calendar.js @@ -1,15 +1,15 @@ /* eslint react/no-multi-comp:0, no-console:0 */ -import 'rc-calendar/assets/index.less'; +import '@seafile/seafile-calendar/assets/index.less'; import React from 'react'; import ReactDOM from 'react-dom'; -import FullCalendar from 'rc-calendar/src/FullCalendar'; +import FullCalendar from '@seafile/seafile-calendar/src/FullCalendar'; import 'rc-select/assets/index.css'; import Select from 'rc-select'; -import zhCN from 'rc-calendar/src/locale/zh_CN'; -import enUS from 'rc-calendar/src/locale/en_US'; +import zhCN from '@seafile/seafile-calendar/src/locale/zh_CN'; +import enUS from '@seafile/seafile-calendar/src/locale/en_US'; import moment from 'moment'; import 'moment/locale/zh-cn'; diff --git a/examples/getCalendarContainer.js b/examples/getCalendarContainer.js index fe3c4fd1a..cc596bb15 100644 --- a/examples/getCalendarContainer.js +++ b/examples/getCalendarContainer.js @@ -1,13 +1,13 @@ -import 'rc-calendar/assets/index.less'; +import '@seafile/seafile-calendar/assets/index.less'; import React from 'react'; import ReactDOM from 'react-dom'; -import Calendar from 'rc-calendar'; -import DatePicker from 'rc-calendar/src/Picker'; +import Calendar from '@seafile/seafile-calendar'; +import DatePicker from '@seafile/seafile-calendar/src/Picker'; import Dialog from 'rc-dialog'; import 'rc-dialog/assets/index.css'; -import zhCN from 'rc-calendar/src/locale/zh_CN'; -import enUS from 'rc-calendar/src/locale/en_US'; +import zhCN from '@seafile/seafile-calendar/src/locale/zh_CN'; +import enUS from '@seafile/seafile-calendar/src/locale/en_US'; import moment from 'moment'; import 'moment/locale/zh-cn'; diff --git a/examples/start-end-range.js b/examples/start-end-range.js index 013dfd1de..2d78f1404 100644 --- a/examples/start-end-range.js +++ b/examples/start-end-range.js @@ -1,13 +1,13 @@ /* eslint react/no-multi-comp:0, no-console:0, react/prop-types:0 */ -import 'rc-calendar/assets/index.less'; +import '@seafile/seafile-calendar/assets/index.less'; import React from 'react'; import ReactDOM from 'react-dom'; -import RangeCalendar from 'rc-calendar/src/RangeCalendar'; -import DatePicker from 'rc-calendar/src/Picker'; +import RangeCalendar from '@seafile/seafile-calendar/src/RangeCalendar'; +import DatePicker from '@seafile/seafile-calendar/src/Picker'; -import zhCN from 'rc-calendar/src/locale/zh_CN'; -import enUS from 'rc-calendar/src/locale/en_US'; +import zhCN from '@seafile/seafile-calendar/src/locale/zh_CN'; +import enUS from '@seafile/seafile-calendar/src/locale/en_US'; import moment from 'moment'; import 'moment/locale/zh-cn'; diff --git a/examples/start-end.js b/examples/start-end.js index 8014be62b..eace02320 100644 --- a/examples/start-end.js +++ b/examples/start-end.js @@ -1,13 +1,13 @@ /* eslint react/no-multi-comp:0, no-console:0 */ -import 'rc-calendar/assets/index.less'; +import '@seafile/seafile-calendar/assets/index.less'; import React from 'react'; import ReactDOM from 'react-dom'; -import Calendar from 'rc-calendar'; -import DatePicker from 'rc-calendar/src/Picker'; +import Calendar from '@seafile/seafile-calendar'; +import DatePicker from '@seafile/seafile-calendar/src/Picker'; -import zhCN from 'rc-calendar/src/locale/zh_CN'; -import enUS from 'rc-calendar/src/locale/en_US'; +import zhCN from '@seafile/seafile-calendar/src/locale/zh_CN'; +import enUS from '@seafile/seafile-calendar/src/locale/en_US'; import 'rc-time-picker/assets/index.css'; import TimePickerPanel from 'rc-time-picker/lib/Panel'; diff --git a/examples/week.js b/examples/week.js index 245b98e02..be76c201b 100644 --- a/examples/week.js +++ b/examples/week.js @@ -1,13 +1,13 @@ /* eslint react/no-multi-comp:0, no-console:0 */ -import 'rc-calendar/assets/index.less'; +import '@seafile/seafile-calendar/assets/index.less'; import React from 'react'; import ReactDOM from 'react-dom'; import PropTypes from 'prop-types'; -import Calendar from 'rc-calendar'; -import DatePicker from 'rc-calendar/src/Picker'; -import zhCN from 'rc-calendar/src/locale/zh_CN'; -import enUS from 'rc-calendar/src/locale/en_US'; +import Calendar from '@seafile/seafile-calendar'; +import DatePicker from '@seafile/seafile-calendar/src/Picker'; +import zhCN from '@seafile/seafile-calendar/src/locale/zh_CN'; +import enUS from '@seafile/seafile-calendar/src/locale/en_US'; import moment from 'moment'; import 'moment/locale/zh-cn'; @@ -27,13 +27,13 @@ const style = ` .week-calendar { width: 386px; } -.week-calendar .rc-calendar-tbody > tr:hover -.rc-calendar-date { +.week-calendar .@seafile/seafile-calendar-tbody > tr:hover +.@seafile/seafile-calendar-date { background: #ebfaff; } -.week-calendar .rc-calendar-tbody > tr:hover -.rc-calendar-selected-day .rc-calendar-date { +.week-calendar .@seafile/seafile-calendar-tbody > tr:hover +.@seafile/seafile-calendar-selected-day .@seafile/seafile-calendar-date { background: #3fc7fa; } @@ -45,7 +45,7 @@ const style = ` width:100px; border-right: 1px solid #ccc; } -.week-calendar .rc-calendar-panel { +.week-calendar .@seafile/seafile-calendar-panel { margin-left: 100px; } `; @@ -78,14 +78,14 @@ class Demo extends React.Component { const selectedValue = this.state.value; if (selectedValue && current.year() === selectedValue.year() && current.week() === selectedValue.week()) { - return (
-
+ return (
+
{current.date()}
); } return ( -
+
{current.date()}
); } diff --git a/package.json b/package.json index e614f3eff..976b0ef75 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "rc-calendar", - "version": "9.15.5", + "name": "@seafile/seafile-calendar", + "version": "0.0.3", "description": "React Calendar", "keywords": [ "react", @@ -20,14 +20,14 @@ ], "main": "lib/index", "module": "es/index", - "homepage": "http://github.com/react-component/calendar", - "author": "yiminghe@gmail.com", + "homepage": "https://github.com/seafileltd/calendar", + "author": "seafile", "repository": { "type": "git", - "url": "git@github.com:react-component/calendar.git" + "url": "https://github.com/seafileltd/calendar.git" }, "bugs": { - "url": "http://github.com/react-component/calendar/issues" + "url": "https://github.com/seafileltd/calendar/issues" }, "licenses": "MIT", "config": { diff --git a/src/Calendar.jsx b/src/Calendar.jsx index 2e8d89898..623308c5c 100644 --- a/src/Calendar.jsx +++ b/src/Calendar.jsx @@ -6,6 +6,7 @@ import { polyfill } from 'react-lifecycles-compat'; import DateTable from './date/DateTable'; import CalendarHeader from './calendar/CalendarHeader'; import CalendarFooter from './calendar/CalendarFooter'; +import CalendarRightPanel from './calendar/CalendarRightPanel'; import { calendarMixinWrapper, calendarMixinPropTypes, @@ -45,6 +46,7 @@ class Calendar extends React.Component { showWeekNumber: PropTypes.bool, showToday: PropTypes.bool, showOk: PropTypes.bool, + showTimeAndHour: PropTypes.bool, onSelect: PropTypes.func, onOk: PropTypes.func, onKeyDown: PropTypes.func, @@ -69,6 +71,7 @@ class Calendar extends React.Component { ...defaultProp, showToday: true, showDateInput: true, + showTimeAndHour: false, timePicker: null, onOk: noop, onPanelChange: noop, @@ -274,7 +277,7 @@ class Calendar extends React.Component { const { locale, prefixCls, disabledDate, dateInputPlaceholder, timePicker, - disabledTime, clearIcon, renderFooter, inputMode, + disabledTime, clearIcon, renderFooter, inputMode, showTimeAndHour, } = props; const { value, selectedValue, mode } = state; const showTimePicker = mode === 'time'; @@ -328,6 +331,7 @@ class Calendar extends React.Component { } children.push(
{dateInputElement} +
+ {showTimeAndHour && + + } +
); return this.renderRoot({ diff --git a/src/calendar/CalendarRightPanel.jsx b/src/calendar/CalendarRightPanel.jsx new file mode 100644 index 000000000..0c45b320c --- /dev/null +++ b/src/calendar/CalendarRightPanel.jsx @@ -0,0 +1,72 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import moment from 'moment'; + +export default class CalendarRightPanel extends React.Component { + + static propTypes = { + prefixCls: PropTypes.string, + value: PropTypes.object, + onSelect: PropTypes.func, + } + + constructor(props) { + super(props); + this.state = { + highlightTime: this.props.value || null, + }; + this.timeRef = React.createRef(); + } + + onSelect = (value) => { + this.setState({ + highlightTime: value, + }); + this.props.onSelect(value); + } + + scrollUp = () => { + this.timeRef.current.scrollBy(0, -200); + } + + scrollDown = () => { + this.timeRef.current.scrollBy(0, 200); + } + + render() { + const { value, prefixCls } = this.props; + const selectedDate = value.format().slice(0, 10); + const times = []; + for (let i = 0; i < 24; i++) { + const str = (String(i) + ':00').padStart(5, '0'); + const str1 = (String(i) + ':30').padStart(5, '0'); + times.push(str); + times.push(str1); + } + return ( +
+
+ +
+
+
    + {times.map((time) => { + const current = moment(selectedDate + ' ' + time); + const isHightlight = current.isSame(this.state.highlightTime) ? 'highlight' : ''; + return ( +
  • {time}
  • + ); + })} +
+
+
+ +
+
+ ); + } +} From e4459ad744ea44227b60472b9ce202767f0c9de2 Mon Sep 17 00:00:00 2001 From: Michael An <1822852997@qq.com> Date: Sat, 24 Aug 2019 16:52:45 +0800 Subject: [PATCH 02/41] change default color --- assets/common/FullCalendar.less | 12 ++++++------ assets/index/Calendar.less | 18 +++++++++--------- assets/index/DecadePanel.less | 8 ++++---- assets/index/Input.less | 6 +++--- assets/index/MonthPanel.less | 8 ++++---- assets/index/TimePanel.less | 6 +++--- assets/index/YearPanel.less | 8 ++++---- src/Calendar.jsx | 2 +- src/calendar/CalendarRightPanel.jsx | 6 +++--- 9 files changed, 37 insertions(+), 37 deletions(-) diff --git a/assets/common/FullCalendar.less b/assets/common/FullCalendar.less index b2713e218..4c8d66a20 100644 --- a/assets/common/FullCalendar.less +++ b/assets/common/FullCalendar.less @@ -19,13 +19,13 @@ float: right; display: inline-block; &-normal:hover { - border-color: #23c0fa; + border-color: #f09f4g; box-shadow: 0 0 2px rgba(45, 183, 245, 0.8); cursor: pointer; } &-focus { - border-color: #3fc7fa; - background-color: #3fc7fa; + border-color: #f09f3f; + background-color: #f09f3f; color: #fff; } > span { @@ -79,13 +79,13 @@ } &-selected-day .@{prefixClass}-date, &-month-panel-selected-cell .@{prefixClass}-month-panel-month { - background-color: #ebfaff; + background-color: #fcecd9; color: #666; } &-today .@{prefixClass}-date, &-month-panel-selected-cell .@{prefixClass}-month-panel-month { - border-top-color: #3FC7FA; - color: #3FC7FA; + border-top-color: #f09f3f; + color: #f09f3f; } } } diff --git a/assets/index/Calendar.less b/assets/index/Calendar.less index ad26d4ffa..4bb221464 100644 --- a/assets/index/Calendar.less +++ b/assets/index/Calendar.less @@ -52,7 +52,7 @@ &:hover { cursor: pointer; - color: #23c0fa; + color: #f09f4g; } } @@ -85,7 +85,7 @@ &:hover { cursor: pointer; - color: #23c0fa; + color: #f09f4g; } &.@{prefixClass}-time-status:hover{ cursor: pointer; @@ -108,7 +108,7 @@ line-height: 34px; &:hover { - color: #23c0fa; + color: #f09f4g; } } @@ -243,25 +243,25 @@ text-align: center; &:hover { - background: #ebfaff; + background: #fcecd9; cursor: pointer; } } &-selected-day &-date { - background: tint(#3fc7fa, 80%); + background: tint(#f09f3f, 80%); } &-selected-date &-date { - background: #3fc7fa; + background: #f09f3f; color: #fff; &:hover { - background: #3fc7fa; + background: #f09f3f; } } &-today &-date { - border: 1px solid #3fc7fa; + border: 1px solid #f09f3f; } &-disabled-cell &-date { @@ -344,7 +344,7 @@ &:hover { cursor: pointer; - color: #23c0fa; + color: #f09f4g; } &-disabled { diff --git a/assets/index/DecadePanel.less b/assets/index/DecadePanel.less index f83c591d0..e8dcbd734 100644 --- a/assets/index/DecadePanel.less +++ b/assets/index/DecadePanel.less @@ -34,7 +34,7 @@ &:hover { cursor: pointer; - color: #23c0fa; + color: #f09f4g; } } } @@ -96,17 +96,17 @@ text-align: center; &:hover { - background: #ebfaff; + background: #fcecd9; cursor: pointer; } } .@{prefixClass}-decade-panel-selected-cell .@{prefixClass}-decade-panel-decade { - background: #3fc7fa; + background: #f09f3f; color: #fff; &:hover { - background: #3fc7fa; + background: #f09f3f; color: #fff; } } diff --git a/assets/index/Input.less b/assets/index/Input.less index ac081bc23..9ea3caa2c 100644 --- a/assets/index/Input.less +++ b/assets/index/Input.less @@ -12,11 +12,11 @@ transform: border 0.3s cubic-bezier(0.35, 0, 0.25, 1), background 0.3s cubic-bezier(0.35, 0, 0.25, 1), box-shadow 0.3s cubic-bezier(0.35, 0, 0.25, 1); &:hover { - border-color: #23c0fa; + border-color: #f09f4g; } &:focus { - border-color: #23c0fa; - box-shadow: 0 0 3px #23c0fa; + border-color: #f09f4g; + box-shadow: 0 0 3px #f09f4g; } } \ No newline at end of file diff --git a/assets/index/MonthPanel.less b/assets/index/MonthPanel.less index 1b35f0e6b..7a9fac133 100644 --- a/assets/index/MonthPanel.less +++ b/assets/index/MonthPanel.less @@ -38,7 +38,7 @@ &:hover { cursor: pointer; - color: #23c0fa; + color: #f09f4g; } } } @@ -111,7 +111,7 @@ text-align: center; &:hover { - background: #ebfaff; + background: #fcecd9; cursor: pointer; } } @@ -129,11 +129,11 @@ } .@{prefixClass}-month-panel-selected-cell .@{prefixClass}-month-panel-month { - background: #3fc7fa; + background: #f09f3f; color: #fff; &:hover { - background: #3fc7fa; + background: #f09f3f; color: #fff; } } diff --git a/assets/index/TimePanel.less b/assets/index/TimePanel.less index 6701a53c7..afcf7a78a 100644 --- a/assets/index/TimePanel.less +++ b/assets/index/TimePanel.less @@ -57,18 +57,18 @@ margin: 0 auto; &:hover { - background: #ebfaff; + background: #fcecd9; cursor: pointer; } } .@{prefixClass}-time-panel-selected-cell .@{prefixClass}-time-panel-time { - background: #3fc7fa; + background: #f09f3f; color: #fff; &:hover { - background: #3fc7fa; + background: #f09f3f; color: #fff; } } \ No newline at end of file diff --git a/assets/index/YearPanel.less b/assets/index/YearPanel.less index 6b31dc8ec..cbdb0fc3d 100644 --- a/assets/index/YearPanel.less +++ b/assets/index/YearPanel.less @@ -38,7 +38,7 @@ &:hover { cursor: pointer; - color: #23c0fa; + color: #f09f4g; } } } @@ -110,17 +110,17 @@ text-align: center; &:hover { - background: #ebfaff; + background: #fcecd9; cursor: pointer; } } .@{prefixClass}-year-panel-selected-cell .@{prefixClass}-year-panel-year { - background: #3fc7fa; + background: #f09f3f; color: #fff; &:hover { - background: #3fc7fa; + background: #f09f3f; color: #fff; } } diff --git a/src/Calendar.jsx b/src/Calendar.jsx index 623308c5c..76a7dfbd7 100644 --- a/src/Calendar.jsx +++ b/src/Calendar.jsx @@ -390,7 +390,7 @@ class Calendar extends React.Component { onCloseTimePicker={this.closeTimePicker} />
- {showTimeAndHour && + {!showTimeAndHour &&
@@ -52,12 +53,11 @@ export default class CalendarRightPanel extends React.Component {
    {times.map((time) => { const current = moment(selectedDate + ' ' + time); - const isHightlight = current.isSame(this.state.highlightTime) ? 'highlight' : ''; return (
  • {time}
  • ); })} From 9a16248917f6987c3fe385ace12e6bf20a0ecad4 Mon Sep 17 00:00:00 2001 From: Michael An <1822852997@qq.com> Date: Sat, 24 Aug 2019 17:16:35 +0800 Subject: [PATCH 03/41] update readme --- README.md | 6 ++++++ src/Calendar.jsx | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f02550fef..da32aad3b 100644 --- a/README.md +++ b/README.md @@ -195,6 +195,12 @@ http://react-component.github.io/calendar/examples/index.html auto whether has ok button in footer + + showHourAndMinute + Boolean + auto + whether has hour-minute chooser in the right panel(for dtable date column) + timePicker React Element diff --git a/src/Calendar.jsx b/src/Calendar.jsx index 76a7dfbd7..4f2366287 100644 --- a/src/Calendar.jsx +++ b/src/Calendar.jsx @@ -46,7 +46,7 @@ class Calendar extends React.Component { showWeekNumber: PropTypes.bool, showToday: PropTypes.bool, showOk: PropTypes.bool, - showTimeAndHour: PropTypes.bool, + showHourAndMinute: PropTypes.bool, onSelect: PropTypes.func, onOk: PropTypes.func, onKeyDown: PropTypes.func, @@ -71,7 +71,7 @@ class Calendar extends React.Component { ...defaultProp, showToday: true, showDateInput: true, - showTimeAndHour: false, + showHourAndMinute: false, timePicker: null, onOk: noop, onPanelChange: noop, @@ -277,7 +277,7 @@ class Calendar extends React.Component { const { locale, prefixCls, disabledDate, dateInputPlaceholder, timePicker, - disabledTime, clearIcon, renderFooter, inputMode, showTimeAndHour, + disabledTime, clearIcon, renderFooter, inputMode, showHourAndMinute, } = props; const { value, selectedValue, mode } = state; const showTimePicker = mode === 'time'; @@ -390,7 +390,7 @@ class Calendar extends React.Component { onCloseTimePicker={this.closeTimePicker} />
- {!showTimeAndHour && + {showHourAndMinute && Date: Sat, 24 Aug 2019 17:17:37 +0800 Subject: [PATCH 04/41] update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 976b0ef75..aac4e10a0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@seafile/seafile-calendar", - "version": "0.0.3", + "version": "0.0.4", "description": "React Calendar", "keywords": [ "react", From 60e568a4da07d3f19924cd3b2aabe8d4280bd9ea Mon Sep 17 00:00:00 2001 From: Michael An <1822852997@qq.com> Date: Mon, 26 Aug 2019 15:41:45 +0800 Subject: [PATCH 05/41] change default time to 08:00 --- package.json | 2 +- src/calendar/CalendarRightPanel.jsx | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index aac4e10a0..602ce2869 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@seafile/seafile-calendar", - "version": "0.0.4", + "version": "0.0.5", "description": "React Calendar", "keywords": [ "react", diff --git a/src/calendar/CalendarRightPanel.jsx b/src/calendar/CalendarRightPanel.jsx index 5daa40b94..b50245515 100644 --- a/src/calendar/CalendarRightPanel.jsx +++ b/src/calendar/CalendarRightPanel.jsx @@ -33,6 +33,11 @@ export default class CalendarRightPanel extends React.Component { this.timeRef.current.scrollBy(0, 200); } + componentDidMount() { + // The default time is 8, page scroll to 08:00 + this.timeRef.current.scrollTo(0, 34 * 16); + } + render() { const { value, prefixCls } = this.props; const selectedDate = value.format().slice(0, 10); From 09cef9ce7c845cd41785f882d774b3acef2c5a9d Mon Sep 17 00:00:00 2001 From: Michael An <1822852997@qq.com> Date: Tue, 27 Aug 2019 15:39:13 +0800 Subject: [PATCH 06/41] update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 602ce2869..f07f8f605 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@seafile/seafile-calendar", - "version": "0.0.5", + "version": "0.0.6", "description": "React Calendar", "keywords": [ "react", From b2c738711b960dc17ca5fbca9c0f4737f48b54fa Mon Sep 17 00:00:00 2001 From: Michael An <1822852997@qq.com> Date: Thu, 29 Aug 2019 10:40:16 +0800 Subject: [PATCH 07/41] set right panel locale --- src/Calendar.jsx | 1 + src/calendar/CalendarRightPanel.jsx | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Calendar.jsx b/src/Calendar.jsx index 4f2366287..12ed1ab80 100644 --- a/src/Calendar.jsx +++ b/src/Calendar.jsx @@ -394,6 +394,7 @@ class Calendar extends React.Component { } diff --git a/src/calendar/CalendarRightPanel.jsx b/src/calendar/CalendarRightPanel.jsx index b50245515..8e77bf24c 100644 --- a/src/calendar/CalendarRightPanel.jsx +++ b/src/calendar/CalendarRightPanel.jsx @@ -8,6 +8,7 @@ export default class CalendarRightPanel extends React.Component { prefixCls: PropTypes.string, value: PropTypes.object, onSelect: PropTypes.func, + locale: PropTypes.object, } constructor(props) { @@ -39,7 +40,7 @@ export default class CalendarRightPanel extends React.Component { } render() { - const { value, prefixCls } = this.props; + const { value, prefixCls, locale } = this.props; const selectedDate = value.format().slice(0, 10); const times = []; for (let i = 0; i < 24; i++) { @@ -49,6 +50,7 @@ export default class CalendarRightPanel extends React.Component { times.push(str1); } const highlightTime = this.state.highlightTime ? this.state.highlightTime.format().slice(11, 16) : null; + const isEnGb = (locale && locale.year === 'Year'); return (
@@ -57,7 +59,8 @@ export default class CalendarRightPanel extends React.Component {
    {times.map((time) => { - const current = moment(selectedDate + ' ' + time); + let current = moment(selectedDate + ' ' + time); + current = isEnGb ? current.locale('en-gb').utcOffset(0) : current.locale('zh-cn').utcOffset(8); return (
  • Date: Thu, 29 Aug 2019 10:56:09 +0800 Subject: [PATCH 08/41] update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f07f8f605..ef3406906 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@seafile/seafile-calendar", - "version": "0.0.6", + "version": "0.0.7", "description": "React Calendar", "keywords": [ "react", From 270b31734395c5922bb9231eaf4fdf1e24c5a132 Mon Sep 17 00:00:00 2001 From: Michael An <1822852997@qq.com> Date: Thu, 29 Aug 2019 11:21:34 +0800 Subject: [PATCH 09/41] update version --- package.json | 2 +- src/calendar/CalendarRightPanel.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ef3406906..f1ccf05e8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@seafile/seafile-calendar", - "version": "0.0.7", + "version": "0.0.8", "description": "React Calendar", "keywords": [ "react", diff --git a/src/calendar/CalendarRightPanel.jsx b/src/calendar/CalendarRightPanel.jsx index 8e77bf24c..af2e6a9cb 100644 --- a/src/calendar/CalendarRightPanel.jsx +++ b/src/calendar/CalendarRightPanel.jsx @@ -60,7 +60,7 @@ export default class CalendarRightPanel extends React.Component {
      {times.map((time) => { let current = moment(selectedDate + ' ' + time); - current = isEnGb ? current.locale('en-gb').utcOffset(0) : current.locale('zh-cn').utcOffset(8); + current = isEnGb ? current.locale('en-gb') : current.locale('zh-cn'); return (
    • Date: Tue, 3 Dec 2019 10:33:57 +0800 Subject: [PATCH 10/41] set Sunday as the first day of the week --- examples/antd-calendar.js | 1 + src/calendar/CalendarRightPanel.jsx | 19 ++++++++++--------- src/date/DateTBody.jsx | 5 ++++- src/date/DateTHead.jsx | 4 +++- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/examples/antd-calendar.js b/examples/antd-calendar.js index af7fa46f9..2db2769c2 100644 --- a/examples/antd-calendar.js +++ b/examples/antd-calendar.js @@ -150,6 +150,7 @@ class Demo extends React.Component { showDateInput={state.showDateInput} disabledDate={disabledDate} focusablePanel={false} + showHourAndMinute />); return (
      diff --git a/src/calendar/CalendarRightPanel.jsx b/src/calendar/CalendarRightPanel.jsx index af2e6a9cb..e439429ef 100644 --- a/src/calendar/CalendarRightPanel.jsx +++ b/src/calendar/CalendarRightPanel.jsx @@ -19,6 +19,11 @@ export default class CalendarRightPanel extends React.Component { this.timeRef = React.createRef(); } + componentDidMount() { + // The default time is 8, page scroll to 08:00 + this.timeRef.current.scrollTo(0, 34 * 16); + } + onSelect = (value) => { this.setState({ highlightTime: value, @@ -34,22 +39,18 @@ export default class CalendarRightPanel extends React.Component { this.timeRef.current.scrollBy(0, 200); } - componentDidMount() { - // The default time is 8, page scroll to 08:00 - this.timeRef.current.scrollTo(0, 34 * 16); - } - render() { const { value, prefixCls, locale } = this.props; const selectedDate = value.format().slice(0, 10); const times = []; for (let i = 0; i < 24; i++) { - const str = (String(i) + ':00').padStart(5, '0'); - const str1 = (String(i) + ':30').padStart(5, '0'); + const str = (`${String(i)}:00`).padStart(5, '0'); + const str1 = (`${String(i)}:30`).padStart(5, '0'); times.push(str); times.push(str1); } - const highlightTime = this.state.highlightTime ? this.state.highlightTime.format().slice(11, 16) : null; + const highlight = this.state.highlightTime; + const highlightTime = highlight ? highlight.format().slice(11, 16) : null; const isEnGb = (locale && locale.year === 'Year'); return (
      @@ -59,7 +60,7 @@ export default class CalendarRightPanel extends React.Component {
        {times.map((time) => { - let current = moment(selectedDate + ' ' + time); + let current = moment(`${selectedDate} ${time}`); current = isEnGb ? current.locale('en-gb') : current.locale('zh-cn'); return (
      • Date: Tue, 3 Dec 2019 10:50:00 +0800 Subject: [PATCH 11/41] update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f1ccf05e8..1a351b1d9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@seafile/seafile-calendar", - "version": "0.0.8", + "version": "0.0.9", "description": "React Calendar", "keywords": [ "react", From 9ade1657af0b352cd66148a49d16d055c34206ab Mon Sep 17 00:00:00 2001 From: Michael An <1822852997@qq.com> Date: Tue, 3 Dec 2019 11:09:52 +0800 Subject: [PATCH 12/41] update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1a351b1d9..68652033d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@seafile/seafile-calendar", - "version": "0.0.9", + "version": "0.0.10", "description": "React Calendar", "keywords": [ "react", From 79d2b6208682d372855f1797f2718047a681b36b Mon Sep 17 00:00:00 2001 From: Michael An <1822852997@qq.com> Date: Thu, 23 Apr 2020 11:15:31 +0800 Subject: [PATCH 13/41] set default locale is enUS --- src/calendar/CalendarRightPanel.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calendar/CalendarRightPanel.jsx b/src/calendar/CalendarRightPanel.jsx index e439429ef..192bea2c4 100644 --- a/src/calendar/CalendarRightPanel.jsx +++ b/src/calendar/CalendarRightPanel.jsx @@ -51,7 +51,7 @@ export default class CalendarRightPanel extends React.Component { } const highlight = this.state.highlightTime; const highlightTime = highlight ? highlight.format().slice(11, 16) : null; - const isEnGb = (locale && locale.year === 'Year'); + const isZhcn = (locale && locale.today === '今天'); return (
        @@ -61,7 +61,7 @@ export default class CalendarRightPanel extends React.Component {
          {times.map((time) => { let current = moment(`${selectedDate} ${time}`); - current = isEnGb ? current.locale('en-gb') : current.locale('zh-cn'); + current = isZhcn ? current.locale('zh-cn') : current.locale('en-gb'); return (
        • Date: Fri, 24 Apr 2020 11:01:32 +0800 Subject: [PATCH 14/41] update --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 68652033d..4c0bd3a0d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@seafile/seafile-calendar", - "version": "0.0.10", + "version": "0.0.11", "description": "React Calendar", "keywords": [ "react", From 1462024673f094724c3d07db798168683001c97a Mon Sep 17 00:00:00 2001 From: Michael An <1822852997@qq.com> Date: Sat, 9 May 2020 18:01:51 +0800 Subject: [PATCH 15/41] change classname --- assets/index/Calendar.less | 2 +- src/calendar/CalendarRightPanel.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/index/Calendar.less b/assets/index/Calendar.less index 4bb221464..8b6a096bc 100644 --- a/assets/index/Calendar.less +++ b/assets/index/Calendar.less @@ -165,7 +165,7 @@ ul li:hover { color: #e8bf6a; } - ul li.highlight { + .@{prefixClass}-selected-time { color: #f09f3f; } &::-webkit-scrollbar { diff --git a/src/calendar/CalendarRightPanel.jsx b/src/calendar/CalendarRightPanel.jsx index 192bea2c4..3326bdd28 100644 --- a/src/calendar/CalendarRightPanel.jsx +++ b/src/calendar/CalendarRightPanel.jsx @@ -66,7 +66,7 @@ export default class CalendarRightPanel extends React.Component {
        • {time}
        • ); })} From b6f96467d7b1d6a58268f501318a38f711c147e5 Mon Sep 17 00:00:00 2001 From: Michael An <1822852997@qq.com> Date: Sat, 9 May 2020 21:58:40 +0800 Subject: [PATCH 16/41] update version to 0.0.12 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4c0bd3a0d..72640e8e1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@seafile/seafile-calendar", - "version": "0.0.11", + "version": "0.0.12", "description": "React Calendar", "keywords": [ "react", From a1565d58c62f3794a03cafb44e3c9ecb2d3ed4d8 Mon Sep 17 00:00:00 2001 From: Michael An <1822852997@qq.com> Date: Tue, 1 Sep 2020 17:31:50 +0800 Subject: [PATCH 17/41] change right panel click callback --- .travis.yml | 3 +-- README.md | 6 ++++++ examples/antd-calendar.js | 5 +++++ index.d.ts | 3 ++- package.json | 2 +- src/Calendar.jsx | 5 ++++- src/calendar/CalendarRightPanel.jsx | 4 +++- 7 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7aff03e0c..5c04fd525 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,8 +4,7 @@ sudo: false notifications: email: - - yiminghe@gmail.com - - hust2012jiangkai@gmail.com + - bing.an@seafile.com node_js: - 10 diff --git a/README.md b/README.md index da32aad3b..6cc73412a 100644 --- a/README.md +++ b/README.md @@ -231,6 +231,12 @@ http://react-component.github.io/calendar/examples/index.html called when ok button is pressed, only if it's visible + + onClickRightPanelTime + Function() + + called when right panel hour and minute is clicked, only prop showHourAndMinute is true + dateInputPlaceholder String diff --git a/examples/antd-calendar.js b/examples/antd-calendar.js index 2db2769c2..06479c651 100644 --- a/examples/antd-calendar.js +++ b/examples/antd-calendar.js @@ -129,6 +129,10 @@ class Demo extends React.Component { }); } + onClickRightPanelTime = () => { + this.onOpenChange(false); + } + getCalendarContainer = () => this.calendarContainerRef.current; toggleDisabled = () => { @@ -151,6 +155,7 @@ class Demo extends React.Component { disabledDate={disabledDate} focusablePanel={false} showHourAndMinute + onClickRightPanelTime={this.onClickRightPanelTime} />); return (
          diff --git a/index.d.ts b/index.d.ts index f1edde5e7..8ae68c177 100644 --- a/index.d.ts +++ b/index.d.ts @@ -25,6 +25,7 @@ export interface Props { onSelect?: (date: Moment) => void; onOk?: () => void; onKeyDown?: () => void; + onClickRightPanelTime?: () => void; timePicker?: React.ReactNode; dateInputPlaceholder?: string; onClear?: () => void; @@ -35,7 +36,7 @@ export interface Props { dateRender?: (current: Moment, value: Moment) => React.ReactNode; renderFooter?: () => React.ReactNode; renderSidebar?: () => React.ReactNode; - inputMode?:String + inputMode?: string; } export default class ReactCalendar extends React.Component {} diff --git a/package.json b/package.json index 72640e8e1..170f23386 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@seafile/seafile-calendar", - "version": "0.0.12", + "version": "0.0.13", "description": "React Calendar", "keywords": [ "react", diff --git a/src/Calendar.jsx b/src/Calendar.jsx index 12ed1ab80..abeccea0d 100644 --- a/src/Calendar.jsx +++ b/src/Calendar.jsx @@ -64,6 +64,7 @@ class Calendar extends React.Component { focusablePanel: PropTypes.bool, inputMode: PropTypes.string, onBlur: PropTypes.func, + onClickRightPanelTime: PropTypes.func, } static defaultProps = { @@ -75,6 +76,7 @@ class Calendar extends React.Component { timePicker: null, onOk: noop, onPanelChange: noop, + onClickRightPanelTime: noop, focusablePanel: true, } @@ -276,7 +278,7 @@ class Calendar extends React.Component { const { props, state } = this; const { locale, prefixCls, disabledDate, - dateInputPlaceholder, timePicker, + dateInputPlaceholder, timePicker, onClickRightPanelTime, disabledTime, clearIcon, renderFooter, inputMode, showHourAndMinute, } = props; const { value, selectedValue, mode } = state; @@ -396,6 +398,7 @@ class Calendar extends React.Component { value={value} locale={locale} onSelect={this.onDateTableSelect} + onClickRightPanelTime={onClickRightPanelTime} /> }
          diff --git a/src/calendar/CalendarRightPanel.jsx b/src/calendar/CalendarRightPanel.jsx index 3326bdd28..4c69288e7 100644 --- a/src/calendar/CalendarRightPanel.jsx +++ b/src/calendar/CalendarRightPanel.jsx @@ -8,6 +8,7 @@ export default class CalendarRightPanel extends React.Component { prefixCls: PropTypes.string, value: PropTypes.object, onSelect: PropTypes.func, + onClickRightPanelTime: PropTypes.func, locale: PropTypes.object, } @@ -29,6 +30,7 @@ export default class CalendarRightPanel extends React.Component { highlightTime: value, }); this.props.onSelect(value); + this.props.onClickRightPanelTime(); } scrollUp = () => { @@ -66,7 +68,7 @@ export default class CalendarRightPanel extends React.Component {
        • {time}
        • ); })} From a3e5ade8ea2dea049773fd14fb75411f6f4c3947 Mon Sep 17 00:00:00 2001 From: zxj96 <519213124@qq.com> Date: Fri, 9 Apr 2021 17:32:40 +0800 Subject: [PATCH 18/41] Choose precise time to improve --- package.json | 2 +- src/Calendar.jsx | 2 ++ src/calendar/CalendarRightPanel.jsx | 28 ++++++++++++++++++---------- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 170f23386..0ac2fb88b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@seafile/seafile-calendar", - "version": "0.0.13", + "version": "0.0.15", "description": "React Calendar", "keywords": [ "react", diff --git a/src/Calendar.jsx b/src/Calendar.jsx index abeccea0d..1495affb2 100644 --- a/src/Calendar.jsx +++ b/src/Calendar.jsx @@ -47,6 +47,7 @@ class Calendar extends React.Component { showToday: PropTypes.bool, showOk: PropTypes.bool, showHourAndMinute: PropTypes.bool, + defaultMinutesTime: PropTypes.string, onSelect: PropTypes.func, onOk: PropTypes.func, onKeyDown: PropTypes.func, @@ -399,6 +400,7 @@ class Calendar extends React.Component { locale={locale} onSelect={this.onDateTableSelect} onClickRightPanelTime={onClickRightPanelTime} + defaultMinutesTime={this.props.defaultMinutesTime} /> }
          diff --git a/src/calendar/CalendarRightPanel.jsx b/src/calendar/CalendarRightPanel.jsx index 4c69288e7..87f896762 100644 --- a/src/calendar/CalendarRightPanel.jsx +++ b/src/calendar/CalendarRightPanel.jsx @@ -10,6 +10,7 @@ export default class CalendarRightPanel extends React.Component { onSelect: PropTypes.func, onClickRightPanelTime: PropTypes.func, locale: PropTypes.object, + defaultMinutesTime: PropTypes.string, } constructor(props) { @@ -18,11 +19,14 @@ export default class CalendarRightPanel extends React.Component { highlightTime: this.props.value || null, }; this.timeRef = React.createRef(); + this.times = this.getTimes(); } componentDidMount() { - // The default time is 8, page scroll to 08:00 - this.timeRef.current.scrollTo(0, 34 * 16); + const { defaultMinutesTime } = this.props; + const showTimeIndex = this.times.findIndex(item => item === defaultMinutesTime); + const scrollTimeIndex = showTimeIndex > -1 ? showTimeIndex : 16; + this.timeRef.current.scrollTo(0, 34 * scrollTimeIndex); } onSelect = (value) => { @@ -33,6 +37,17 @@ export default class CalendarRightPanel extends React.Component { this.props.onClickRightPanelTime(); } + getTimes = () => { + const times = []; + for (let i = 0; i < 24; i++) { + const str = (`${String(i)}:00`).padStart(5, '0'); + const str1 = (`${String(i)}:30`).padStart(5, '0'); + times.push(str); + times.push(str1); + } + return times; + } + scrollUp = () => { this.timeRef.current.scrollBy(0, -200); } @@ -44,13 +59,6 @@ export default class CalendarRightPanel extends React.Component { render() { const { value, prefixCls, locale } = this.props; const selectedDate = value.format().slice(0, 10); - const times = []; - for (let i = 0; i < 24; i++) { - const str = (`${String(i)}:00`).padStart(5, '0'); - const str1 = (`${String(i)}:30`).padStart(5, '0'); - times.push(str); - times.push(str1); - } const highlight = this.state.highlightTime; const highlightTime = highlight ? highlight.format().slice(11, 16) : null; const isZhcn = (locale && locale.today === '今天'); @@ -61,7 +69,7 @@ export default class CalendarRightPanel extends React.Component {
          - {times.map((time) => { + {this.times.map((time) => { let current = moment(`${selectedDate} ${time}`); current = isZhcn ? current.locale('zh-cn') : current.locale('en-gb'); return ( From 062781409f1525d5fa8a5a73d7a490071f138c60 Mon Sep 17 00:00:00 2001 From: zxj96 <519213124@qq.com> Date: Thu, 17 Feb 2022 17:08:02 +0800 Subject: [PATCH 19/41] dayjs replace moment --- assets/index/Calendar.less | 2 +- examples/antd-calendar.js | 30 +- examples/antd-month-calendar.js | 13 +- examples/antd-range-calendar.js | 29 +- examples/custom-clear-icon.js | 4 +- examples/full-calendar.js | 14 +- examples/getCalendarContainer.js | 14 +- examples/start-end-range.js | 14 +- examples/start-end.js | 14 +- examples/week.js | 30 +- index.d.ts | 20 +- package.json | 4 +- rc-calendar-tests.tsx | 8 +- src/Calendar.jsx | 12 +- src/FullCalendar.jsx | 4 +- src/MonthCalendar.jsx | 16 +- src/RangeCalendar.js | 8 +- src/calendar/CalendarHeader.jsx | 8 +- src/calendar/CalendarRightPanel.jsx | 4 +- src/date/DateInput.js | 9 +- src/date/DateTBody.jsx | 10 +- src/date/DateTHead.jsx | 23 +- src/decade/DecadePanel.jsx | 10 +- src/full-calendar/CalendarHeader.jsx | 12 +- src/mixin/CalendarMixin.js | 4 +- src/month/MonthTable.js | 20 +- src/util/index.js | 19 +- src/year/YearPanel.jsx | 10 +- tests/Calendar.spec.jsx | 105 +- tests/FullCalendar.spec.js | 15 +- tests/MonthCalendar.spec.js | 21 +- tests/Picker.spec.jsx | 57 +- tests/RangeCalendar.spec.jsx | 111 +- tests/__snapshots__/Calendar.spec.jsx.snap | 9306 +-- tests/__snapshots__/FullCalendar.spec.js.snap | 336 +- .../__snapshots__/RangeCalendar.spec.jsx.snap | 866 +- tests/__snapshots__/locale.spec.js.snap | 56238 ++++++++-------- 37 files changed, 33860 insertions(+), 33560 deletions(-) diff --git a/assets/index/Calendar.less b/assets/index/Calendar.less index 8b6a096bc..1d3fd3312 100644 --- a/assets/index/Calendar.less +++ b/assets/index/Calendar.less @@ -2,7 +2,7 @@ position: relative; outline: none; font-family: Arial, "Hiragino Sans GB", "Microsoft Yahei", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans-serif; - width: fit-content; + width: 253px; border: 1px solid #ccc; list-style: none; font-size: 12px; diff --git a/examples/antd-calendar.js b/examples/antd-calendar.js index 06479c651..5c29ac1a2 100644 --- a/examples/antd-calendar.js +++ b/examples/antd-calendar.js @@ -11,18 +11,24 @@ import enUS from '@seafile/seafile-calendar/src/locale/en_US'; import 'rc-time-picker/assets/index.css'; import TimePickerPanel from 'rc-time-picker/lib/Panel'; -import moment from 'moment'; -import 'moment/locale/zh-cn'; -import 'moment/locale/en-gb'; +import dayjs from 'dayjs'; +import 'dayjs/locale/zh-cn'; +import 'dayjs/locale/en-gb'; + +import localeData from 'dayjs/plugin/localeData'; +import utc from 'dayjs/plugin/utc'; const format = 'YYYY-MM-DD HH:mm:ss'; -const cn = location.search.indexOf('cn') !== -1; +const cn = true; + +dayjs.extend(utc); +dayjs.extend(localeData); -const now = moment(); +let now = dayjs(); if (cn) { - now.locale('zh-cn').utcOffset(8); + now = now.locale('zh-cn'); } else { - now.locale('en-gb').utcOffset(0); + now = now.locale('en-gb'); } function getFormat(time) { @@ -33,7 +39,7 @@ function getFormat(time) { const defaultCalendarValue = now.clone(); defaultCalendarValue.add(-1, 'month'); -const timePickerElement = ; +const timePickerElement = ; function disabledTime(date) { console.log('disabledTime', date); @@ -57,10 +63,10 @@ function disabledDate(current) { // allow empty select return false; } - const date = moment(); - date.hour(0); - date.minute(0); - date.second(0); + let date = dayjs().locale('zh-cn'); + date = date.hour(0); + date = date.minute(0); + date = date.second(0); return current.valueOf() < date.valueOf(); // can not select days before today } diff --git a/examples/antd-month-calendar.js b/examples/antd-month-calendar.js index 86f1620ec..c4750674e 100644 --- a/examples/antd-month-calendar.js +++ b/examples/antd-month-calendar.js @@ -9,15 +9,18 @@ import DatePicker from '@seafile/seafile-calendar/src/Picker'; import zhCN from '@seafile/seafile-calendar/src/locale/zh_CN'; import enUS from '@seafile/seafile-calendar/src/locale/en_US'; - -import moment from 'moment'; -import 'moment/locale/zh-cn'; -import 'moment/locale/en-gb'; +import dayjs from 'dayjs'; +import localeData from 'dayjs/plugin/localeData'; +import utc from 'dayjs/plugin/utc'; +import 'dayjs/locale/zh-cn'; +import 'dayjs/locale/en-gb'; +dayjs.extend(utc); +dayjs.extend(localeData); const format = 'YYYY-MM'; const cn = location.search.indexOf('cn') !== -1; -const now = moment(); +const now = dayjs(); if (cn) { now.locale('zh-cn').utcOffset(8); } else { diff --git a/examples/antd-range-calendar.js b/examples/antd-range-calendar.js index 63620dfeb..bf119322e 100644 --- a/examples/antd-range-calendar.js +++ b/examples/antd-range-calendar.js @@ -10,19 +10,26 @@ import TimePickerPanel from 'rc-time-picker/lib/Panel'; import '@seafile/seafile-calendar/assets/index.less'; import 'rc-time-picker/assets/index.css'; -import moment from 'moment'; -import 'moment/locale/zh-cn'; -import 'moment/locale/en-gb'; +import dayjs from 'dayjs'; +import localeData from 'dayjs/plugin/localeData'; +import utc from 'dayjs/plugin/utc'; +import weekOfYear from 'dayjs/plugin/weekOfYear'; +import 'dayjs/locale/zh-cn'; +import 'dayjs/locale/en-gb'; +dayjs.extend(utc); +dayjs.extend(localeData); +dayjs.extend(weekOfYear); + const cn = location.search.indexOf('cn') !== -1; if (cn) { - moment.locale('zh-cn'); + dayjs.locale('zh-cn'); } else { - moment.locale('en-gb'); + dayjs.locale('en-gb'); } -const now = moment(); +const now = dayjs(); if (cn) { now.utcOffset(8); } else { @@ -34,7 +41,7 @@ defaultCalendarValue.add(-1, 'month'); const timePickerElement = ( ); @@ -47,10 +54,10 @@ function newArray(start, end) { } function disabledDate(current) { - const date = moment(); - date.hour(0); - date.minute(0); - date.second(0); + let date = dayjs(); + date = date.hour(0); + date = date.minute(0); + date = date.second(0); return current.isBefore(date); // can not select days before today } diff --git a/examples/custom-clear-icon.js b/examples/custom-clear-icon.js index f5f6fe71d..74f8fa565 100644 --- a/examples/custom-clear-icon.js +++ b/examples/custom-clear-icon.js @@ -7,8 +7,8 @@ import Calendar from '@seafile/seafile-calendar'; import RangeCalendar from '@seafile/seafile-calendar/src/RangeCalendar'; import 'rc-time-picker/assets/index.css'; -import 'moment/locale/zh-cn'; -import 'moment/locale/en-gb'; +import 'dayjs/locale/zh-cn'; +import 'dayjs/locale/en-gb'; const clearPath = 'M909.1 209.3l-56.4 44.1C775.8 155.1 656.2 92 521.9 92 ' + '290 92 102.3 279.5 102 511.5 101.7 743.7 289.8 932 521.9 932c181.3 0' + diff --git a/examples/full-calendar.js b/examples/full-calendar.js index 5936b70df..2847d2f91 100644 --- a/examples/full-calendar.js +++ b/examples/full-calendar.js @@ -11,14 +11,20 @@ import Select from 'rc-select'; import zhCN from '@seafile/seafile-calendar/src/locale/zh_CN'; import enUS from '@seafile/seafile-calendar/src/locale/en_US'; -import moment from 'moment'; -import 'moment/locale/zh-cn'; -import 'moment/locale/en-gb'; +import dayjs from 'dayjs'; +import localeData from 'dayjs/plugin/localeData'; +import utc from 'dayjs/plugin/utc'; +import weekOfYear from 'dayjs/plugin/weekOfYear'; +import 'dayjs/locale/zh-cn'; +import 'dayjs/locale/en-gb'; +dayjs.extend(utc); +dayjs.extend(localeData); +dayjs.extend(weekOfYear); const format = 'YYYY-MM-DD'; const cn = location.search.indexOf('cn') !== -1; -const now = moment(); +const now = dayjs(); if (cn) { now.locale('zh-cn').utcOffset(8); } else { diff --git a/examples/getCalendarContainer.js b/examples/getCalendarContainer.js index cc596bb15..9ed981c4b 100644 --- a/examples/getCalendarContainer.js +++ b/examples/getCalendarContainer.js @@ -9,14 +9,20 @@ import 'rc-dialog/assets/index.css'; import zhCN from '@seafile/seafile-calendar/src/locale/zh_CN'; import enUS from '@seafile/seafile-calendar/src/locale/en_US'; -import moment from 'moment'; -import 'moment/locale/zh-cn'; -import 'moment/locale/en-gb'; +import dayjs from 'dayjs'; +import localeData from 'dayjs/plugin/localeData'; +import utc from 'dayjs/plugin/utc'; +import weekOfYear from 'dayjs/plugin/weekOfYear'; +import 'dayjs/locale/zh-cn'; +import 'dayjs/locale/en-gb'; +dayjs.extend(utc); +dayjs.extend(localeData); +dayjs.extend(weekOfYear); const format = 'YYYY-MM-DD'; const cn = location.search.indexOf('cn') !== -1; -const now = moment(); +const now = dayjs(); if (cn) { now.locale('zh-cn').utcOffset(8); } else { diff --git a/examples/start-end-range.js b/examples/start-end-range.js index 2d78f1404..0c495e8c0 100644 --- a/examples/start-end-range.js +++ b/examples/start-end-range.js @@ -9,16 +9,22 @@ import DatePicker from '@seafile/seafile-calendar/src/Picker'; import zhCN from '@seafile/seafile-calendar/src/locale/zh_CN'; import enUS from '@seafile/seafile-calendar/src/locale/en_US'; -import moment from 'moment'; -import 'moment/locale/zh-cn'; -import 'moment/locale/en-gb'; +import dayjs from 'dayjs'; +import localeData from 'dayjs/plugin/localeData'; +import utc from 'dayjs/plugin/utc'; +import weekOfYear from 'dayjs/plugin/weekOfYear'; +import 'dayjs/locale/zh-cn'; +import 'dayjs/locale/en-gb'; +dayjs.extend(utc); +dayjs.extend(localeData); +dayjs.extend(weekOfYear); const format = 'YYYY-MM-DD'; const fullFormat = 'YYYY-MM-DD dddd'; const cn = location.search.indexOf('cn') !== -1; -const now = moment(); +const now = dayjs(); if (cn) { now.locale('zh-cn').utcOffset(8); } else { diff --git a/examples/start-end.js b/examples/start-end.js index eace02320..2226d6b27 100644 --- a/examples/start-end.js +++ b/examples/start-end.js @@ -11,14 +11,20 @@ import enUS from '@seafile/seafile-calendar/src/locale/en_US'; import 'rc-time-picker/assets/index.css'; import TimePickerPanel from 'rc-time-picker/lib/Panel'; -import moment from 'moment'; -import 'moment/locale/zh-cn'; -import 'moment/locale/en-gb'; +import dayjs from 'dayjs'; +import localeData from 'dayjs/plugin/localeData'; +import utc from 'dayjs/plugin/utc'; +import weekOfYear from 'dayjs/plugin/weekOfYear'; +import 'dayjs/locale/zh-cn'; +import 'dayjs/locale/en-gb'; +dayjs.extend(utc); +dayjs.extend(localeData); +dayjs.extend(weekOfYear); const format = 'YYYY-MM-DD HH:mm:ss'; const cn = location.search.indexOf('cn') !== -1; -const now = moment(); +const now = dayjs(); if (cn) { now.locale('zh-cn').utcOffset(8); } else { diff --git a/examples/week.js b/examples/week.js index be76c201b..6138fefe0 100644 --- a/examples/week.js +++ b/examples/week.js @@ -9,14 +9,22 @@ import DatePicker from '@seafile/seafile-calendar/src/Picker'; import zhCN from '@seafile/seafile-calendar/src/locale/zh_CN'; import enUS from '@seafile/seafile-calendar/src/locale/en_US'; -import moment from 'moment'; -import 'moment/locale/zh-cn'; -import 'moment/locale/en-gb'; - -const format = 'YYYY-Wo'; +import dayjs from 'dayjs'; +import localeData from 'dayjs/plugin/localeData'; +import utc from 'dayjs/plugin/utc'; +import weekOfYear from 'dayjs/plugin/weekOfYear'; +import advancedFormat from 'dayjs/plugin/advancedFormat'; +import 'dayjs/locale/zh-cn'; +import 'dayjs/locale/en-gb'; +dayjs.extend(utc); +dayjs.extend(localeData); +dayjs.extend(weekOfYear); +dayjs.extend(advancedFormat); + +const format = 'YYYY-wo'; const cn = location.search.indexOf('cn') !== -1; -const now = moment(); +const now = dayjs(); if (cn) { now.locale('zh-cn').utcOffset(8); } else { @@ -78,21 +86,21 @@ class Demo extends React.Component { const selectedValue = this.state.value; if (selectedValue && current.year() === selectedValue.year() && current.week() === selectedValue.week()) { - return (
          -
          + return (
          +
          {current.date()}
          ); } return ( -
          +
          {current.date()}
          ); } lastWeek = () => { - const value = this.state.value || now; - value.add(-1, 'weeks'); + let value = this.state.value || now; + value = value.add(-1, 'weeks'); this.setState({ value, open: false, diff --git a/index.d.ts b/index.d.ts index 8ae68c177..13e00bf9f 100644 --- a/index.d.ts +++ b/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/react-component/calendar import * as React from 'react'; -import { Moment } from 'moment'; +import { Dayjs } from 'dayjs'; export type Mode = 'time' | 'date' | 'month' | 'year' | 'decade'; @@ -12,9 +12,9 @@ export interface Props { prefixCls?: string; className?: string; style?: React.CSSProperties; - defaultValue?: Moment; - value?: Moment; - selectedValue?: Moment; + defaultValue?: Dayjs; + value?: Dayjs; + selectedValue?: Dayjs; mode?: Mode; locale?: object; format?: string | string[]; @@ -22,18 +22,18 @@ export interface Props { showWeekNumber?: boolean; showToday?: boolean; showOk?: boolean; - onSelect?: (date: Moment) => void; + onSelect?: (date: Dayjs) => void; onOk?: () => void; onKeyDown?: () => void; onClickRightPanelTime?: () => void; timePicker?: React.ReactNode; dateInputPlaceholder?: string; onClear?: () => void; - onChange?: (date: Moment | null) => void; - onPanelChange?: (date: Moment | null, mode: Mode) => void; - disabledDate?: (current: Moment | undefined) => boolean; - disabledTime?: (current: Moment | undefined) => object; - dateRender?: (current: Moment, value: Moment) => React.ReactNode; + onChange?: (date: Dayjs | null) => void; + onPanelChange?: (date: Dayjs | null, mode: Mode) => void; + disabledDate?: (current: Dayjs | undefined) => boolean; + disabledTime?: (current: Dayjs | undefined) => object; + dateRender?: (current: Dayjs, value: Dayjs) => React.ReactNode; renderFooter?: () => React.ReactNode; renderSidebar?: () => React.ReactNode; inputMode?: string; diff --git a/package.json b/package.json index 0ac2fb88b..bd5ff17c3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@seafile/seafile-calendar", - "version": "0.0.15", + "version": "0.0.16", "description": "React Calendar", "keywords": [ "react", @@ -91,7 +91,7 @@ "dependencies": { "babel-runtime": "6.x", "classnames": "2.x", - "moment": "2.x", + "dayjs": "1.10.7", "prop-types": "^15.5.8", "rc-trigger": "^2.2.0", "rc-util": "^4.1.1", diff --git a/rc-calendar-tests.tsx b/rc-calendar-tests.tsx index b4e37931f..afa4d690f 100644 --- a/rc-calendar-tests.tsx +++ b/rc-calendar-tests.tsx @@ -1,8 +1,8 @@ import * as React from 'react'; -import * as moment from 'moment'; +import * as dayjs from 'dayjs'; import Calendar from './'; -const action = (date: moment.Moment) => { +const action = (date: dayjs.Dayjs) => { date.subtract(1); }; @@ -10,11 +10,11 @@ export default () => ( false} + disabledDate={(now: dayjs.Dayjs) => false} onSelect={action} inputMode="numeric" /> diff --git a/src/Calendar.jsx b/src/Calendar.jsx index 1495affb2..dbe76d353 100644 --- a/src/Calendar.jsx +++ b/src/Calendar.jsx @@ -3,6 +3,7 @@ import ReactDOM from 'react-dom'; import PropTypes from 'prop-types'; import KeyCode from 'rc-util/lib/KeyCode'; import { polyfill } from 'react-lifecycles-compat'; +import dayjs from 'dayjs'; import DateTable from './date/DateTable'; import CalendarHeader from './calendar/CalendarHeader'; import CalendarFooter from './calendar/CalendarFooter'; @@ -17,13 +18,18 @@ import { commonMixinWrapper, propType, defaultProp } from './mixin/CommonMixin'; import DateInput from './date/DateInput'; import { getTimeConfig, getTodayTime, syncTime } from './util'; import { goStartMonth, goEndMonth, goTime } from './util/toTime'; -import moment from 'moment'; +import localeData from 'dayjs/plugin/localeData'; +import utc from 'dayjs/plugin/utc'; +import weekOfYear from 'dayjs/plugin/weekOfYear'; +dayjs.extend(utc); +dayjs.extend(localeData); +dayjs.extend(weekOfYear); function noop() { } const getMomentObjectIfValid = date => { - if (moment.isMoment(date) && date.isValid()) { + if (dayjs.isDayjs(date) && date.isValid()) { return date; } return false; @@ -88,7 +94,7 @@ class Calendar extends React.Component { value: getMomentObjectIfValid(props.value) || getMomentObjectIfValid(props.defaultValue) || - moment(), + dayjs(), selectedValue: props.selectedValue || props.defaultSelectedValue, }; } diff --git a/src/FullCalendar.jsx b/src/FullCalendar.jsx index 90fdb7f66..4a8cb19dc 100644 --- a/src/FullCalendar.jsx +++ b/src/FullCalendar.jsx @@ -11,7 +11,7 @@ import { } from './mixin/CalendarMixin'; import { commonMixinWrapper, propType, defaultProp } from './mixin/CommonMixin'; import CalendarHeader from './full-calendar/CalendarHeader'; -import moment from 'moment'; +import dayjs from 'dayjs'; class FullCalendar extends React.Component { static propTypes = { @@ -61,7 +61,7 @@ class FullCalendar extends React.Component { this.state = { type, - value: props.value || props.defaultValue || moment(), + value: props.value || props.defaultValue || dayjs(), selectedValue: props.selectedValue || props.defaultSelectedValue, }; } diff --git a/src/MonthCalendar.jsx b/src/MonthCalendar.jsx index 857f2f617..bbee730ef 100644 --- a/src/MonthCalendar.jsx +++ b/src/MonthCalendar.jsx @@ -10,7 +10,7 @@ import { calendarMixinDefaultProps, } from './mixin/CalendarMixin'; import { commonMixinWrapper, propType, defaultProp } from './mixin/CommonMixin'; -import moment from 'moment'; +import dayjs from 'dayjs'; class MonthCalendar extends React.Component { static propTypes = { @@ -31,7 +31,7 @@ class MonthCalendar extends React.Component { this.state = { mode: 'month', - value: props.value || props.defaultValue || moment(), + value: props.value || props.defaultValue || dayjs(), selectedValue: props.selectedValue || props.defaultSelectedValue, }; } @@ -45,26 +45,26 @@ class MonthCalendar extends React.Component { switch (keyCode) { case KeyCode.DOWN: value = stateValue.clone(); - value.add(3, 'months'); + value = value.add(3, 'months'); break; case KeyCode.UP: value = stateValue.clone(); - value.add(-3, 'months'); + value = value.add(-3, 'months'); break; case KeyCode.LEFT: value = stateValue.clone(); if (ctrlKey) { - value.add(-1, 'years'); + value = value.add(-1, 'years'); } else { - value.add(-1, 'months'); + value = value.add(-1, 'months'); } break; case KeyCode.RIGHT: value = stateValue.clone(); if (ctrlKey) { - value.add(1, 'years'); + value = value.add(1, 'years'); } else { - value.add(1, 'months'); + value = value.add(1, 'months'); } break; case KeyCode.ENTER: diff --git a/src/RangeCalendar.js b/src/RangeCalendar.js index 0c2f938da..9b5deb8ce 100644 --- a/src/RangeCalendar.js +++ b/src/RangeCalendar.js @@ -1,6 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; -import moment from 'moment'; +import dayjs from 'dayjs'; import classnames from 'classnames'; import { polyfill } from 'react-lifecycles-compat'; import KeyCode from 'rc-util/lib/KeyCode'; @@ -50,7 +50,7 @@ function normalizeAnchor(props, init) { getValueFromSelectedValue(value) : getValueFromSelectedValue(selectedValue); return !isEmptyArray(normalizedValue) ? - normalizedValue : init && [moment(), moment().add(1, 'months')]; + normalizedValue : init && [dayjs(), dayjs().add(1, 'months')]; } function generateOptions(length, extraOptionGen) { @@ -210,7 +210,7 @@ class RangeCalendar extends React.Component { let nextHoverValue; if (!firstSelectedValue) { - currentHoverTime = hoverValue[0] || selectedValue[0] || value[0] || moment(); + currentHoverTime = hoverValue[0] || selectedValue[0] || value[0] || dayjs(); nextHoverTime = func(currentHoverTime); nextHoverValue = [nextHoverTime]; this.fireHoverValueChange(nextHoverValue); @@ -571,7 +571,7 @@ class RangeCalendar extends React.Component { // 尚未选择过时间,直接输入的话 if (!this.state.selectedValue[0] || !this.state.selectedValue[1]) { - const startValue = selectedValue[0] || moment(); + const startValue = selectedValue[0] || dayjs(); const endValue = selectedValue[1] || startValue.clone().add(1, 'months'); this.setState({ selectedValue, diff --git a/src/calendar/CalendarHeader.jsx b/src/calendar/CalendarHeader.jsx index a7eccfc17..2c4817922 100644 --- a/src/calendar/CalendarHeader.jsx +++ b/src/calendar/CalendarHeader.jsx @@ -6,14 +6,14 @@ import YearPanel from '../year/YearPanel'; import DecadePanel from '../decade/DecadePanel'; function goMonth(direction) { - const next = this.props.value.clone(); - next.add(direction, 'months'); + let next = this.props.value.clone(); + next = next.add(direction, 'months'); this.props.onValueChange(next); } function goYear(direction) { - const next = this.props.value.clone(); - next.add(direction, 'years'); + let next = this.props.value.clone(); + next = next.add(direction, 'years'); this.props.onValueChange(next); } diff --git a/src/calendar/CalendarRightPanel.jsx b/src/calendar/CalendarRightPanel.jsx index 87f896762..8497b5eaf 100644 --- a/src/calendar/CalendarRightPanel.jsx +++ b/src/calendar/CalendarRightPanel.jsx @@ -1,6 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; -import moment from 'moment'; +import dayjs from 'dayjs'; export default class CalendarRightPanel extends React.Component { @@ -70,7 +70,7 @@ export default class CalendarRightPanel extends React.Component {
            {this.times.map((time) => { - let current = moment(`${selectedDate} ${time}`); + let current = dayjs(`${selectedDate} ${time}`); current = isZhcn ? current.locale('zh-cn') : current.locale('en-gb'); return (
          • {getMonthName(t)} diff --git a/src/mixin/CalendarMixin.js b/src/mixin/CalendarMixin.js index 49a2fe3eb..0165fe14e 100644 --- a/src/mixin/CalendarMixin.js +++ b/src/mixin/CalendarMixin.js @@ -1,7 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; -import moment from 'moment'; +import dayjs from 'dayjs'; import { isAllowedDate, getTodayTime } from '../util/index'; function noop() { @@ -12,7 +12,7 @@ export function getNowByCurrentStateValue(value) { if (value) { ret = getTodayTime(value); } else { - ret = moment(); + ret = dayjs(); } return ret; } diff --git a/src/month/MonthTable.js b/src/month/MonthTable.js index 2b5a6348e..c78cfd2c7 100644 --- a/src/month/MonthTable.js +++ b/src/month/MonthTable.js @@ -7,8 +7,8 @@ const ROW = 4; const COL = 3; function chooseMonth(month) { - const next = this.state.value.clone(); - next.month(month); + let next = this.state.value.clone(); + next = next.month(month); this.setAndSelectValue(next); } @@ -42,13 +42,13 @@ class MonthTable extends Component { months() { const value = this.state.value; - const current = value.clone(); + let current = value.clone(); const months = []; let index = 0; for (let rowIndex = 0; rowIndex < ROW; rowIndex++) { months[rowIndex] = []; for (let colIndex = 0; colIndex < COL; colIndex++) { - current.month(index); + current = current.month(index); const content = getMonthName(current); months[rowIndex][colIndex] = { value: index, @@ -72,8 +72,8 @@ class MonthTable extends Component { const tds = month.map(monthData => { let disabled = false; if (props.disabledDate) { - const testValue = value.clone(); - testValue.month(monthData.value); + let testValue = value.clone(); + testValue = testValue.month(monthData.value); disabled = props.disabledDate(testValue); } const classNameMap = { @@ -85,14 +85,14 @@ class MonthTable extends Component { }; let cellEl; if (cellRender) { - const currentValue = value.clone(); - currentValue.month(monthData.value); + let currentValue = value.clone(); + currentValue = currentValue.month(monthData.value); cellEl = cellRender(currentValue, locale); } else { let content; if (contentRender) { - const currentValue = value.clone(); - currentValue.month(monthData.value); + let currentValue = value.clone(); + currentValue = currentValue.month(monthData.value); content = contentRender(currentValue, locale); } else { content = monthData.content; diff --git a/src/util/index.js b/src/util/index.js index 59665f68f..73782ab6d 100644 --- a/src/util/index.js +++ b/src/util/index.js @@ -1,4 +1,7 @@ -import moment from 'moment'; +import dayjs from 'dayjs'; +import utc from 'dayjs/plugin/utc'; + +dayjs.extend(utc); const defaultDisabledTime = { disabledHours() { @@ -13,8 +16,8 @@ const defaultDisabledTime = { }; export function getTodayTime(value) { - const today = moment(); - today.locale(value.locale()).utcOffset(value.utcOffset()); + let today = dayjs(); + today = today.locale(value.locale()).utcOffset(value.utcOffset()); return today; } @@ -34,11 +37,11 @@ export function getMonthName(month) { } export function syncTime(from, to) { - if (!moment.isMoment(from) || !moment.isMoment(to)) return; - to.hour(from.hour()); - to.minute(from.minute()); - to.second(from.second()); - to.millisecond(from.millisecond()); + if (!dayjs.isDayjs(from) || !dayjs.isDayjs(to)) return; + to = to.hour(from.hour()); + to = to.minute(from.minute()); + to = to.second(from.second()); + to = to.millisecond(from.millisecond()); } export function getTimeConfig(value, disabledTime) { diff --git a/src/year/YearPanel.jsx b/src/year/YearPanel.jsx index f679a52bd..48dbb67a8 100644 --- a/src/year/YearPanel.jsx +++ b/src/year/YearPanel.jsx @@ -5,17 +5,17 @@ const ROW = 4; const COL = 3; function goYear(direction) { - const value = this.state.value.clone(); - value.add(direction, 'year'); + let value = this.state.value.clone(); + value = value.add(direction, 'year'); this.setState({ value, }); } function chooseYear(year) { - const value = this.state.value.clone(); - value.year(year); - value.month(this.state.value.month()); + let value = this.state.value.clone(); + value = value.year(year); + value = value.month(this.state.value.month()); this.setState({ value, }); diff --git a/tests/Calendar.spec.jsx b/tests/Calendar.spec.jsx index 369eeb86b..01fd5f79a 100644 --- a/tests/Calendar.spec.jsx +++ b/tests/Calendar.spec.jsx @@ -1,25 +1,40 @@ /* eslint-disable no-undef */ import React from 'react'; import keyCode from 'rc-util/lib/KeyCode'; -import moment from 'moment'; +import dayjs from 'dayjs'; import { mount, render } from 'enzyme'; import TimePickerPanel from 'rc-time-picker/lib/Panel'; import Calendar from '../src/Calendar'; import zhCN from '../src/locale/zh_CN'; import enUS from '../src/locale/en_US'; +import localeData from 'dayjs/plugin/localeData'; +import utc from 'dayjs/plugin/utc'; +import weekOfYear from 'dayjs/plugin/weekOfYear'; +import advancedFormat from 'dayjs/plugin/advancedFormat'; +import customParseFormat from 'dayjs/plugin/customParseFormat'; +import badMutable from 'dayjs/plugin/badMutable'; +import 'dayjs/locale/zh-cn'; +import 'dayjs/locale/en-gb'; +dayjs.extend(utc); +dayjs.extend(localeData); +dayjs.extend(weekOfYear); +dayjs.extend(advancedFormat); +dayjs.extend(customParseFormat); +dayjs.extend(badMutable); + const format = ('YYYY-MM-DD'); describe('Calendar', () => { describe('render', () => { it('render correctly', () => { const zhWrapper = render( - + ); expect(zhWrapper).toMatchSnapshot(); const enWrapper = render( - + ); expect(enWrapper).toMatchSnapshot(); @@ -27,15 +42,15 @@ describe('Calendar', () => { const enWrapperWithMonthFormatWrapper = render( ); expect(enWrapperWithMonthFormatWrapper).toMatchSnapshot(); }); - it('render correctly with invalid moment object', () => { + it('render correctly with invalid dayjs object', () => { const enWrapper = render( - + ); expect(enWrapper).toMatchSnapshot(); }); @@ -48,7 +63,7 @@ describe('Calendar', () => { describe('timePicker', () => { it('set defaultOpenValue if timePicker.props.defaultValue is set', () => { - const timePicker = ; + const timePicker = ; const wrapper = mount(); wrapper.find('.rc-calendar-time-picker-btn').simulate('click'); const selectedValues = wrapper.find('.rc-time-picker-panel-select-option-selected'); @@ -58,9 +73,9 @@ describe('Calendar', () => { }); it('follow Calendar[selectedValue|defaultSelectedValue] when it is set', () => { - const timePicker = ; + const timePicker = ; const wrapper = mount( - + ); wrapper.find('.rc-calendar-time-picker-btn').simulate('click'); const selectedValues = wrapper.find('.rc-time-picker-panel-select-option-selected'); @@ -70,7 +85,7 @@ describe('Calendar', () => { }); it('use timePicker\'s time', () => { - const timePicker = ; + const timePicker = ; const wrapper = mount(); wrapper.find('.rc-calendar-today').simulate('click'); @@ -93,7 +108,7 @@ describe('Calendar', () => { ).toBe('3/8/2017 06:00:00'); }); it('timePicker date have no changes when hover', () => { - const timePicker = ; + const timePicker = ; const wrapper = mount(); wrapper.find('.rc-calendar-time-picker-btn').simulate('click'); const dateBtns = wrapper.find('.rc-calendar-my-select a'); @@ -122,7 +137,7 @@ describe('Calendar', () => { }); it('support controlled mode', () => { - const timePicker = ; + const timePicker = ; let value = null; class ControlledCalendar extends React.Component { state = { mode: 'date' }; @@ -155,14 +170,14 @@ describe('Calendar', () => { expect(wrapper.find('.rc-calendar-year-panel').length).toBe(1); wrapper.find('.rc-calendar-year-panel-decade-select').simulate('click'); expect(wrapper.find('.rc-calendar-decade-panel').length).toBe(1); - expect(value.isSame(moment(), 'day')); + expect(value.isSame(dayjs(), 'day')); wrapper.find('.rc-calendar-decade-panel-selected-cell').simulate('click'); expect(wrapper.find('.rc-calendar-decade-panel').length).toBe(0); wrapper.find('.rc-calendar-year-panel-selected-cell').simulate('click'); expect(wrapper.find('.rc-calendar-year-panel').length).toBe(0); wrapper.find('.rc-calendar-month-panel-selected-cell').simulate('click'); expect(wrapper.find('.rc-calendar-month-panel').length).toBe(0); - expect(value.isSame(moment('2010-03-29'), 'day')); + expect(value.isSame(dayjs('2010-03-29'), 'day')); wrapper.find('.rc-calendar-year-select').simulate('click'); expect(wrapper.find('.rc-calendar-year-panel').length).toBe(1); @@ -203,8 +218,8 @@ describe('Calendar', () => { it('left works', () => { const original = calendar.state().value; - const expected = original.clone(); - expected.add(-1, 'day'); + let expected = original.clone(); + expected = expected.add(-1, 'day'); calendar.simulate('keyDown', { keyCode: keyCode.LEFT }); expect(calendar.state().value.date()).toBe(expected.date()); @@ -214,8 +229,8 @@ describe('Calendar', () => { it('right works', () => { const original = calendar.state().value; - const expected = original.clone(); - expected.add(1, 'day'); + let expected = original.clone(); + expected = expected.add(1, 'day'); calendar.simulate('keyDown', { keyCode: keyCode.RIGHT }); expect(calendar.state().value.date()).toBe(expected.date()); expect(input.getDOMNode().value).toBe(''); @@ -223,14 +238,14 @@ describe('Calendar', () => { it('up works', () => { const original = calendar.state().value; - const expected = original.clone(); - expected.add(-7, 'day'); + let expected = original.clone(); + expected = expected.add(-7, 'day'); }); it('left works', () => { const original = calendar.state().value; - const expected = original.clone(); - expected.add(-1, 'day'); + let expected = original.clone(); + expected = expected.add(-1, 'day'); calendar.simulate('keyDown', { keyCode: keyCode.LEFT }); expect(calendar.state().value.date()).toBe(expected.date()); @@ -240,8 +255,8 @@ describe('Calendar', () => { it('right works', () => { const original = calendar.state().value; - const expected = original.clone(); - expected.add(1, 'day'); + let expected = original.clone(); + expected = expected.add(1, 'day'); calendar.simulate('keyDown', { keyCode: keyCode.RIGHT }); expect(calendar.state().value.date()).toBe(expected.date()); expect(input.getDOMNode().value).toBe(''); @@ -249,8 +264,8 @@ describe('Calendar', () => { it('up works', () => { const original = calendar.state().value; - const expected = original.clone(); - expected.add(-7, 'day'); + let expected = original.clone(); + expected = expected.add(-7, 'day'); calendar.simulate('keyDown', { keyCode: keyCode.UP }); expect(calendar.state().value.date()).toBe(expected.date()); expect(input.getDOMNode().value).toBe(''); @@ -258,8 +273,8 @@ describe('Calendar', () => { it('down works', () => { const original = calendar.state().value; - const expected = original.clone(); - expected.add(7, 'day'); + let expected = original.clone(); + expected = expected.add(7, 'day'); calendar.simulate('keyDown', { keyCode: keyCode.DOWN }); expect(calendar.state().value.date()).toBe(expected.date()); expect(input.getDOMNode().value).toBe(''); @@ -267,8 +282,8 @@ describe('Calendar', () => { it('pageDown works', () => { const original = calendar.state().value; - const expected = original.clone(); - expected.add(1, 'month'); + let expected = original.clone(); + expected = expected.add(1, 'month'); calendar.simulate('keyDown', { keyCode: keyCode.PAGE_DOWN }); expect(calendar.state().value.month()).toBe(expected.month()); expect(input.getDOMNode().value).toBe(''); @@ -276,8 +291,8 @@ describe('Calendar', () => { it('pageUp works', () => { const original = calendar.state().value; - const expected = original.clone(); - expected.add(-1, 'month'); + let expected = original.clone(); + expected = expected.add(-1, 'month'); calendar.simulate('keyDown', { keyCode: keyCode.PAGE_UP }); expect(calendar.state().value.month()).toBe(expected.month()); expect(input.getDOMNode().value).toBe(''); @@ -285,8 +300,8 @@ describe('Calendar', () => { it('ctrl left works', () => { const original = calendar.state().value; - const expected = original.clone(); - expected.add(-1, 'year'); + let expected = original.clone(); + expected = expected.add(-1, 'year'); calendar.simulate('keyDown', { keyCode: keyCode.LEFT, ctrlKey: 1, @@ -297,8 +312,8 @@ describe('Calendar', () => { it('ctrl right works', () => { const original = calendar.state().value; - const expected = original.clone(); - expected.add(1, 'year'); + let expected = original.clone(); + expected = expected.add(1, 'year'); calendar.simulate('keyDown', { keyCode: keyCode.RIGHT, ctrlKey: 1, @@ -351,10 +366,10 @@ describe('Calendar', () => { if (!current) { return false; } - const date = moment(); - date.hour(0); - date.minute(0); - date.second(0); + let date = dayjs(); + date = date.hour(0); + date = date.minute(0); + date = date.second(0); return current.valueOf() < date.valueOf(); } @@ -587,7 +602,7 @@ describe('Calendar', () => { }); it('handle clear', () => { - const now = moment(); + const now = dayjs(); const calendar = mount( ); @@ -598,7 +613,7 @@ describe('Calendar', () => { describe('onOk', () => { it('triggers onOk', () => { - const selected = moment().add(1, 'day'); + const selected = dayjs().add(1, 'day'); const handleOk = jest.fn(); const calendar = mount( @@ -618,7 +633,7 @@ describe('Calendar', () => { }); it('does not triggers onOk if selected date is disabled', () => { - const selected = moment().add(1, 'day'); + const selected = dayjs().add(1, 'day'); const handleOk = jest.fn(); const calendar = mount( { }); it('today button', () => { - const selected = moment().add(1, 'day').utcOffset(480); + const selected = dayjs().add(1, 'day').utcOffset(480); const calendar = mount( ); calendar.find('.rc-calendar-today-btn').simulate('click'); - expect(moment().isSame(calendar.state().selectedValue)).toBe(true); + expect(dayjs().isSame(calendar.state().selectedValue)).toBe(true); }); }); diff --git a/tests/FullCalendar.spec.js b/tests/FullCalendar.spec.js index 75969ba24..4caf9e560 100644 --- a/tests/FullCalendar.spec.js +++ b/tests/FullCalendar.spec.js @@ -2,9 +2,20 @@ import React from 'react'; import Select from 'rc-select'; import { render, mount } from 'enzyme'; -import moment from 'moment'; +import dayjs from 'dayjs'; import FullCalendar from '../src/FullCalendar'; +import localeData from 'dayjs/plugin/localeData'; +import utc from 'dayjs/plugin/utc'; +import weekOfYear from 'dayjs/plugin/weekOfYear'; +import advancedFormat from 'dayjs/plugin/advancedFormat'; +import 'dayjs/locale/zh-cn'; +import 'dayjs/locale/en-gb'; +dayjs.extend(utc); +dayjs.extend(localeData); +dayjs.extend(weekOfYear); +dayjs.extend(advancedFormat); + describe('FullCalendar', () => { it('renders month mode correctly', () => { const wrapper = render( @@ -82,7 +93,7 @@ describe('FullCalendar', () => { }); it('select month', () => { - const selected = moment().add(1, 'month'); + const selected = dayjs().add(1, 'month'); const wrapper = mount( { it('year or decade panel work correctly', () => { const format = 'YYYY-MM'; @@ -19,7 +30,7 @@ describe('MonthCalendar', () => { describe('keyboard', () => { let wrapper; beforeEach(() => { - const selected = moment().add(2, 'month'); + const selected = dayjs().add(2, 'month'); wrapper = mount(); }); @@ -38,7 +49,7 @@ describe('MonthCalendar', () => { if (!current) { return false; } - const date = moment(); + const date = dayjs(); return current.month() < date.month(); } @@ -114,10 +125,10 @@ describe('MonthCalendar', () => { }); it('controlled value should work', () => { - const wrapper = mount(); + const wrapper = mount(); expect(wrapper.state().value.format('YYYY-MM-DD')).toBe('2000-01-01'); - wrapper.setProps({ value: moment('2049-09-03 00:00:00') }); + wrapper.setProps({ value: dayjs('2049-09-03 00:00:00') }); expect(wrapper.state().value.format('YYYY-MM-DD')).toBe('2049-09-03'); }); }); diff --git a/tests/Picker.spec.jsx b/tests/Picker.spec.jsx index 2eed444d6..0476e9c9f 100644 --- a/tests/Picker.spec.jsx +++ b/tests/Picker.spec.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import moment from 'moment'; +import dayjs from 'dayjs'; import { mount } from 'enzyme'; import keyCode from 'rc-util/lib/KeyCode'; import Calendar from '../index'; @@ -7,8 +7,23 @@ import DatePicker from '../src/Picker'; import RangeCalendar from '../src/RangeCalendar'; import CalendarLocale from '../src/locale/en_US'; +import localeData from 'dayjs/plugin/localeData'; +import utc from 'dayjs/plugin/utc'; +import weekOfYear from 'dayjs/plugin/weekOfYear'; +import advancedFormat from 'dayjs/plugin/advancedFormat'; +import customParseFormat from 'dayjs/plugin/customParseFormat'; +import badMutable from 'dayjs/plugin/badMutable'; +import 'dayjs/locale/zh-cn'; +import 'dayjs/locale/en-gb'; +dayjs.extend(utc); +dayjs.extend(localeData); +dayjs.extend(weekOfYear); +dayjs.extend(advancedFormat); +dayjs.extend(customParseFormat); +dayjs.extend(badMutable); + const format = ('YYYY-MM-DD'); -const VALUE = moment([2015, 5, 1]); +const VALUE = dayjs([2015, 5, 1]); describe('DatePicker', () => { function noop() { @@ -83,9 +98,9 @@ describe('DatePicker', () => { day.simulate('click'); expect(change).not.toBeFalsy(); expect(change.year()).toEqual(2015); - expect(change.month()).toEqual(5); - expect(change.date()).toEqual(2); - expect(input.getDOMNode().value).toEqual('2015-06-02'); + expect(change.month()).toEqual(3); + expect(change.date()).toEqual(28); + expect(input.getDOMNode().value).toEqual('2015-04-28'); expect(picker.state().open).toBeFalsy(); }); @@ -108,12 +123,12 @@ describe('DatePicker', () => { expect(change).not.toBeFalsy(); expect(change.length).toEqual(2); expect(change[0].year()).toEqual(2015); - expect(change[0].month()).toEqual(5); - expect(change[0].date()).toEqual(2); + expect(change[0].month()).toEqual(3); + expect(change[0].date()).toEqual(28); expect(change[1].year()).toEqual(2015); - expect(change[1].month()).toEqual(5); - expect(change[1].date()).toEqual(3); - expect(input.getDOMNode().value).toEqual('2015-06-02 - 2015-06-03'); + expect(change[1].month()).toEqual(3); + expect(change[1].date()).toEqual(29); + expect(input.getDOMNode().value).toEqual('2015-04-28 - 2015-04-29'); expect(picker.state().open).toBeFalsy(); }); @@ -134,7 +149,7 @@ describe('DatePicker', () => { }); it('controlled value', () => { - const value = moment().add(1, 'day'); + const value = dayjs().add(1, 'day'); const picker = renderPicker({ value }); expect(picker.state().value).toBe(value); const nextValue = value.clone().add(1, 'day'); @@ -181,14 +196,14 @@ describe('DatePicker', () => { }); it('close on ok', () => { - const picker = renderPicker({ value: moment() }); + const picker = renderPicker({ value: dayjs() }); picker.find('.rc-calendar-picker-input').simulate('click'); picker.find('.rc-calendar-ok-btn').simulate('click'); expect(picker.state().open).toBe(false); }); it('close on clear', () => { - const picker = renderPicker({ value: moment() }); + const picker = renderPicker({ value: dayjs() }); picker.find('.rc-calendar-picker-input').simulate('click'); picker.find('.rc-calendar-clear-btn').simulate('click'); expect(picker.state().open).toBe(false); @@ -196,7 +211,7 @@ describe('DatePicker', () => { describe('DateInput', () => { it('close on enter', () => { - const picker = renderPicker({ value: moment() }); + const picker = renderPicker({ value: dayjs() }); picker.find('.rc-calendar-picker-input').simulate('click'); picker.find('.rc-calendar-input').simulate('keyDown', { keyCode: keyCode.ENTER, @@ -205,7 +220,7 @@ describe('DatePicker', () => { }); it('not close on enter if disabled date', () => { - const picker = renderPicker({ value: moment() }, { disabledDate: () => true }); + const picker = renderPicker({ value: dayjs() }, { disabledDate: () => true }); picker.find('.rc-calendar-picker-input').simulate('click'); picker.find('.rc-calendar-input').simulate('keyDown', { keyCode: keyCode.ENTER, @@ -229,7 +244,7 @@ describe('DatePicker', () => { }); it('close panel when focus is outside of picker', () => { - const picker = renderPicker({ value: moment() }, undefined, { + const picker = renderPicker({ value: dayjs() }, undefined, { attachTo: container, }); picker.find('.rc-calendar-picker-input').simulate('click'); @@ -242,7 +257,7 @@ describe('DatePicker', () => { it('call onBlur when focus is outside of picker', () => { const handleOnBlur = jest.fn(); - const picker = renderPicker({ value: moment() }, { onBlur: handleOnBlur }, { + const picker = renderPicker({ value: dayjs() }, { onBlur: handleOnBlur }, { attachTo: container, }); @@ -254,7 +269,7 @@ describe('DatePicker', () => { }); it('keep panel opened when clicking on calendar next month', () => { - const picker = renderPicker({ value: moment() }, undefined, { + const picker = renderPicker({ value: dayjs() }, undefined, { attachTo: container, }); @@ -270,7 +285,7 @@ describe('DatePicker', () => { it('does not call onBlur when clicking on calendar next month', () => { const handleOnBlur = jest.fn(); - const picker = renderPicker({ value: moment() }, { onBlur: handleOnBlur }, { + const picker = renderPicker({ value: dayjs() }, { onBlur: handleOnBlur }, { attachTo: container, }); @@ -287,7 +302,7 @@ describe('DatePicker', () => { it('auto focuses the calendar input when opening', () => { jest.useFakeTimers(); - const picker = renderPicker({ value: moment() }); + const picker = renderPicker({ value: dayjs() }); picker.find('.rc-calendar-picker-input').simulate('click'); jest.runAllTimers(); expect(document.activeElement).toBeDefined(); @@ -296,7 +311,7 @@ describe('DatePicker', () => { it('auto focuses the calendar div when date input is not shown', () => { jest.useFakeTimers(); - const picker = renderPicker({ value: moment() }, { showDateInput: false }); + const picker = renderPicker({ value: dayjs() }, { showDateInput: false }); picker.find('.rc-calendar-picker-input').simulate('click'); jest.runAllTimers(); expect(document.activeElement).toBeDefined(); diff --git a/tests/RangeCalendar.spec.jsx b/tests/RangeCalendar.spec.jsx index 7448fe78f..c3f2fd270 100644 --- a/tests/RangeCalendar.spec.jsx +++ b/tests/RangeCalendar.spec.jsx @@ -1,11 +1,26 @@ /* eslint-disable no-undef, max-len, react/no-multi-comp */ import React from 'react'; -import moment from 'moment'; +import dayjs from 'dayjs'; import { mount, render } from 'enzyme'; import keyCode from 'rc-util/lib/KeyCode'; import TimePickerPanel from 'rc-time-picker/lib/Panel'; import RangeCalendar from '../src/RangeCalendar'; +import localeData from 'dayjs/plugin/localeData'; +import utc from 'dayjs/plugin/utc'; +import weekOfYear from 'dayjs/plugin/weekOfYear'; +import advancedFormat from 'dayjs/plugin/advancedFormat'; +import customParseFormat from 'dayjs/plugin/customParseFormat'; +import badMutable from 'dayjs/plugin/badMutable'; +import 'dayjs/locale/zh-cn'; +import 'dayjs/locale/en-gb'; +dayjs.extend(utc); +dayjs.extend(localeData); +dayjs.extend(weekOfYear); +dayjs.extend(advancedFormat); +dayjs.extend(customParseFormat); +dayjs.extend(badMutable); + const format = ('YYYY-MM-DD'); describe('RangeCalendar', () => { @@ -25,7 +40,7 @@ describe('RangeCalendar', () => { }); it('render hoverValue correctly', () => { - const wrapper = render(); + const wrapper = render(); expect(wrapper).toMatchSnapshot(); }); @@ -143,12 +158,11 @@ describe('RangeCalendar', () => { it('onSelect works', () => { function onSelect(d) { - expect(d[0].format(format)).toBe('2015-09-04'); - expect(d[1].format(format)).toBe('2015-10-02'); + expect(d[0].format(format)).toBe('2015-07-31'); + expect(d[1].format(format)).toBe('2015-07-31'); } - const now = moment([2015, 8, 29]); - + const now = dayjs([2015, 8, 29]); const wrapper = mount( { showWeekNumber /> ); - wrapper.find('.rc-calendar-range-left .rc-calendar-date').at(5).simulate('click'); // 9.4 - expect(wrapper.find('.rc-calendar-input').at(0).getDOMNode().value).toBe('2015-09-04'); - wrapper.find('.rc-calendar-range-right .rc-calendar-date').at(5).simulate('click'); // 10.2 - expect(wrapper.find('.rc-calendar-input').at(1).getDOMNode().value).toBe('2015-10-02'); + wrapper.find('.rc-calendar-range-left .rc-calendar-date').at(5).simulate('click'); // 7.31 + expect(wrapper.find('.rc-calendar-input').at(0).getDOMNode().value).toBe('2015-07-31'); + wrapper.find('.rc-calendar-range-right .rc-calendar-date').at(5).simulate('click'); // 7.31 + expect(wrapper.find('.rc-calendar-input').at(1).getDOMNode().value).toBe('2015-07-31'); }); it('onSelect works reversely', () => { function onSelect(d) { - expect(d[0].format(format)).toBe('2015-09-04'); - expect(d[1].format(format)).toBe('2015-09-14'); + expect(d[0].format(format)).toBe('2015-07-31'); + expect(d[1].format(format)).toBe('2015-08-10'); } - const now = moment([2015, 8, 29]); - + const now = dayjs([2015, 8, 29]); const wrapper = mount( { /> ); - wrapper.find('.rc-calendar-range-left .rc-calendar-date').at(15).simulate('click'); // 9.14 - expect(wrapper.find('.rc-calendar-input').at(0).getDOMNode().value).toBe('2015-09-14'); + wrapper.find('.rc-calendar-range-left .rc-calendar-date').at(15).simulate('click'); // 8.10 + expect(wrapper.find('.rc-calendar-input').at(0).getDOMNode().value).toBe('2015-08-10'); - wrapper.find('.rc-calendar-range-left .rc-calendar-date').at(5).simulate('click'); // 9.4 - expect(wrapper.find('.rc-calendar-input').at(0).getDOMNode().value).toBe('2015-09-04'); - expect(wrapper.find('.rc-calendar-input').at(1).getDOMNode().value).toBe('2015-09-14'); + wrapper.find('.rc-calendar-range-left .rc-calendar-date').at(5).simulate('click'); // 7.31 + expect(wrapper.find('.rc-calendar-input').at(0).getDOMNode().value).toBe('2015-07-31'); + expect(wrapper.find('.rc-calendar-input').at(1).getDOMNode().value).toBe('2015-08-10'); }); it('onHoverChange works', () => { @@ -202,8 +215,8 @@ describe('RangeCalendar', () => { describe('timePicker', () => { it('defaultOpenValue should follow RangeCalendar[selectedValue|defaultSelectedValue] when it is set', () => { - const timePicker = ; - const wrapper = mount(); + const timePicker = ; + const wrapper = mount(); wrapper.find('.rc-calendar-time-picker-btn').simulate('click'); const selectedValues = wrapper.find('.rc-time-picker-panel-select-option-selected'); for (let i = 0; i < selectedValues.length; i += 1) { @@ -212,8 +225,8 @@ describe('RangeCalendar', () => { }); it('selected start and end date can be same', () => { - const timePicker = ; - const wrapper = mount(); + const timePicker = ; + const wrapper = mount(); wrapper.find('.rc-calendar-time-picker-btn').simulate('click'); expect(wrapper.find('.rc-calendar-year-select').at(0).text()).toBe('2000'); expect(wrapper.find('.rc-calendar-month-select').at(0).text()).toBe('Sep'); @@ -224,7 +237,7 @@ describe('RangeCalendar', () => { }); it('use timePicker\'s time', () => { - const timePicker = ; + const timePicker = ; const wrapper = mount(); wrapper.find('.rc-calendar-today').at(0).simulate('click').simulate('click'); @@ -296,7 +309,7 @@ describe('RangeCalendar', () => { }, }; } - const timePicker = ; + const timePicker = ; const wrapper = mount(); wrapper.find('.rc-calendar-today').at(0).simulate('click').simulate('click'); @@ -325,7 +338,7 @@ describe('RangeCalendar', () => { it('works fine when select reversely', () => { // see: https://github.com/ant-design/ant-design/issues/6440 - const timePicker = ; + const timePicker = ; const wrapper = mount(); wrapper.find('.rc-calendar-cell').at(20).simulate('click'); wrapper.find('.rc-calendar-cell').at(10).simulate('click'); @@ -371,7 +384,7 @@ describe('RangeCalendar', () => { }, }; } - const timePicker = ; + const timePicker = ; const wrapper = mount(); // update same day wrapper.find('.rc-calendar-today').at(0).simulate('click').simulate('click'); @@ -433,7 +446,7 @@ describe('RangeCalendar', () => { it('should work when start time is null in defaultValue', () => { let wrapper = null; - wrapper = mount(); + wrapper = mount(); wrapper.find('.rc-calendar-range-right .rc-calendar-month-select').simulate('click'); expect(wrapper.find('.rc-calendar-range-left .rc-calendar-next-year-btn').length).toBe(1); expect(wrapper.find('.rc-calendar-range-left .rc-calendar-next-month-btn').length).toBe(1); @@ -445,7 +458,7 @@ describe('RangeCalendar', () => { it('should work when end time is null in defaultValue', () => { let wrapper = null; - wrapper = mount(); + wrapper = mount(); wrapper.find('.rc-calendar-range-right .rc-calendar-month-select').simulate('click'); expect(wrapper.find('.rc-calendar-range-left .rc-calendar-next-year-btn').length).toBe(1); expect(wrapper.find('.rc-calendar-range-left .rc-calendar-next-month-btn').length).toBe(1); @@ -457,7 +470,7 @@ describe('RangeCalendar', () => { it('should work when start time is undefined in defaultValue', () => { let wrapper = null; - wrapper = mount(); + wrapper = mount(); wrapper.find('.rc-calendar-range-right .rc-calendar-month-select').simulate('click'); expect(wrapper.find('.rc-calendar-range-left .rc-calendar-next-year-btn').length).toBe(1); expect(wrapper.find('.rc-calendar-range-left .rc-calendar-next-month-btn').length).toBe(1); @@ -469,7 +482,7 @@ describe('RangeCalendar', () => { it('should work when end time is undefined in defaultValue', () => { let wrapper = null; - wrapper = mount(); + wrapper = mount(); wrapper.find('.rc-calendar-range-right .rc-calendar-month-select').simulate('click'); expect(wrapper.find('.rc-calendar-range-left .rc-calendar-next-year-btn').length).toBe(1); expect(wrapper.find('.rc-calendar-range-left .rc-calendar-next-month-btn').length).toBe(1); @@ -504,8 +517,8 @@ describe('RangeCalendar', () => { wrapper.find('.rc-calendar-year-panel-decade-select').at(0).simulate('click'); wrapper.find('.rc-calendar-year-panel-decade-select').at(0).simulate('click'); expect(wrapper.find('.rc-calendar-decade-panel').length).toBe(2); - expect(value[0].isSame(moment(), 'day')).toBe(true); - expect(value[1].isSame(moment().add(1, 'month'), 'day')).toBe(true); + expect(value[0].isSame(dayjs(), 'day')).toBe(true); + expect(value[1].isSame(dayjs().add(1, 'month'), 'day')).toBe(true); wrapper.find('.rc-calendar-decade-panel-selected-cell').at(0).simulate('click'); wrapper.find('.rc-calendar-decade-panel-selected-cell').at(0).simulate('click'); expect(wrapper.find('.rc-calendar-decade-panel').length).toBe(0); @@ -515,8 +528,8 @@ describe('RangeCalendar', () => { wrapper.find('.rc-calendar-month-panel-selected-cell').at(0).simulate('click'); wrapper.find('.rc-calendar-month-panel-selected-cell').at(0).simulate('click'); expect(wrapper.find('.rc-calendar-month-panel').length).toBe(0); - expect(value[0].isSame(moment('2010-03-29'), 'day')).toBe(true); - expect(value[1].isSame(moment('2010-04-29'), 'day')).toBe(true); + expect(value[0].isSame(dayjs('2010-03-29'), 'day')).toBe(true); + expect(value[1].isSame(dayjs('2010-04-29'), 'day')).toBe(true); wrapper.find('.rc-calendar-year-select').at(0).simulate('click'); wrapper.find('.rc-calendar-year-select').at(1).simulate('click'); @@ -533,11 +546,11 @@ describe('RangeCalendar', () => { }); it('controlled value works correctly', () => { - const wrapper = mount(); + const wrapper = mount(); const initialValue = wrapper.state('value'); expect(initialValue[0].isSame(initialValue[1], 'month')).toBe(true); - wrapper.setProps({ value: [moment(), moment()] }); + wrapper.setProps({ value: [dayjs(), dayjs()] }); const updatedValue = wrapper.state('value'); expect(updatedValue[0].isSame(updatedValue[1], 'month')).toBe(true); }); @@ -547,7 +560,7 @@ describe('RangeCalendar', () => { class Demo extends React.Component { state = { mode: ['month', 'month'], - value: [moment().add(-1, 'day'), moment()], + value: [dayjs().add(-1, 'day'), dayjs()], }; handlePanelChange = (value, mode) => { @@ -581,7 +594,7 @@ describe('RangeCalendar', () => { it('selected item style works correctly with mode year', () => { class Demo extends React.Component { state = { - value: [moment().add(-1, 'year'), moment()], + value: [dayjs().add(-1, 'year'), dayjs()], }; handlePanelChange = (value) => { @@ -637,8 +650,8 @@ describe('RangeCalendar', () => { }); it('controlled hoverValue changes', () => { - const start = moment(); - const end = moment().add(2, 'day'); + const start = dayjs(); + const end = dayjs().add(2, 'day'); const wrapper = mount(); const nextEnd = end.clone().add(2, 'day'); wrapper.setProps({ hoverValue: [start, nextEnd] }); @@ -646,8 +659,8 @@ describe('RangeCalendar', () => { }); it('controlled selectedValue changes', () => { - const start = moment(); - const end = moment().add(2, 'day'); + const start = dayjs(); + const end = dayjs().add(2, 'day'); const wrapper = mount(); const nextEnd = end.clone().add(2, 'day'); wrapper.setProps({ selectedValue: [start, nextEnd] }); @@ -663,8 +676,8 @@ describe('RangeCalendar', () => { beforeEach(() => { handleHoverChange = jest.fn(); - start = moment(); - end = moment().add(2, 'day'); + start = dayjs(); + end = dayjs().add(2, 'day'); wrapper = mount(); }); @@ -685,7 +698,7 @@ describe('RangeCalendar', () => { let keyDownEvent = 0; const wrapper = mount( keyDownEvent = 1} @@ -761,7 +774,7 @@ describe('RangeCalendar', () => { }); it('change input trigger calendar close', () => { - const value = [moment(), moment().add(1, 'months')]; + const value = [dayjs(), dayjs().add(1, 'months')]; const onSelect = jest.fn(); const wrapper = mount( @@ -788,7 +801,7 @@ describe('RangeCalendar', () => { it('date mode should not display same month', () => { const FORMAT = 'YYYY-MM-DD'; - const sameDay = moment('2000-01-01'); + const sameDay = dayjs('2000-01-01'); const wrapper = mount(); // Should in different month @@ -814,7 +827,7 @@ describe('RangeCalendar', () => { mode={['time', 'time']} timePicker={ } />, diff --git a/tests/__snapshots__/Calendar.spec.jsx.snap b/tests/__snapshots__/Calendar.spec.jsx.snap index d87e39193..fadf1466d 100644 --- a/tests/__snapshots__/Calendar.spec.jsx.snap +++ b/tests/__snapshots__/Calendar.spec.jsx.snap @@ -29,938 +29,942 @@ exports[`Calendar controlled panels render controlled panels correctly 1`] = `
          -
          - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
          - 14 -
          - - - - - - - - - - - - - - - - - - - - - - - - - + + Su + + + + + + + + + + + - - - - - - - - - -
          - - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
          -
          - 26 -
          -
          -
          - 27 -
          -
          -
          - 28 -
          -
          -
          - 1 -
          -
          -
          - 2 -
          -
          -
          - 3 -
          -
          -
          - 4 -
          -
          -
          - 5 -
          -
          -
          - 6 -
          -
          -
          - 7 -
          -
          -
          - 8 -
          -
          -
          - 9 -
          -
          -
          - 10 -
          -
          -
          - 11 -
          -
          -
          - 12 -
          -
          -
          - 13 -
          -
          +
          -
          - 15 -
          -
          -
          - 16 -
          -
          -
          - 17 -
          -
          -
          - 18 -
          -
          -
          - 19 -
          -
          -
          - 20 -
          -
          -
          - 21 -
          -
          -
          - 22 -
          -
          -
          - 23 -
          -
          -
          - 24 -
          -
          -
          - 25 -
          -
          -
          - 26 -
          -
          -
          - 27 -
          -
          -
          - 28 -
          -
          -
          - 29 -
          -
          -
          - 30 -
          -
          -
          - 31 -
          -
          -
          - 1 -
          -
          + + Mo + + + + Tu + + + + We + + + + Th + + + + Fr + + + + Sa + +
          -
          - 2 -
          -
          -
          - 3 -
          -
          -
          - 4 -
          -
          -
          - 5 -
          -
          -
          - 6 -
          -
          -
          - 7 -
          -
          -
          - 8 -
          -
          -
          - +
          @@ -996,938 +1000,942 @@ exports[`Calendar controlled panels render controlled panels correctly 2`] = `
        -
        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        - 20 -
        - - - - - - - - - - - - - - - - - + + Su + + + + + + + + + + + - - - - - - - - - -
        - - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
        -
        - 26 -
        -
        -
        - 27 -
        -
        -
        - 28 -
        -
        -
        - 1 -
        -
        -
        - 2 -
        -
        -
        - 3 -
        -
        -
        - 4 -
        -
        -
        - 5 -
        -
        -
        - 6 -
        -
        -
        - 7 -
        -
        -
        - 8 -
        -
        -
        - 9 -
        -
        -
        - 10 -
        -
        -
        - 11 -
        -
        -
        - 12 -
        -
        -
        - 13 -
        -
        -
        - 14 -
        -
        -
        - 15 -
        -
        -
        - 16 -
        -
        -
        - 17 -
        -
        -
        - 18 -
        -
        -
        - 19 -
        -
        +
        -
        - 21 -
        -
        -
        - 22 -
        -
        -
        - 23 -
        -
        -
        - 24 -
        -
        -
        - 25 -
        -
        -
        - 26 -
        -
        -
        - 27 -
        -
        -
        - 28 -
        -
        -
        - 29 -
        -
        -
        - 30 -
        -
        -
        - 31 -
        -
        -
        - 1 -
        -
        + + Mo + + + + Tu + + + + We + + + + Th + + + + Fr + + + + Sa + +
        -
        - 2 -
        -
        -
        - 3 -
        -
        -
        - 4 -
        -
        -
        - 5 -
        -
        -
        - 6 -
        -
        -
        - 7 -
        -
        -
        - 8 -
        -
        -
        - +
      @@ -1963,740 +1971,744 @@ exports[`Calendar render render correctly 1`] = `
@@ -2732,740 +2744,744 @@ exports[`Calendar render render correctly 2`] = `
@@ -3501,747 +3517,751 @@ exports[`Calendar render render correctly 3`] = `
- - - - March - + title="Last year (Control + left)" + /> + - 2017 - - - - -
-
-
- - - - - - - - - - - - - + + + + + +
+
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - + - - Sa - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- 25 -
- -
- - - - - - - - - - + + Su + + + + + + + + + + + - - - - - - - - - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
+
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
+ + Mo + + + + Tu + + + + We + + + + Th + + + + Fr + + + + Sa + +
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
`; -exports[`Calendar render render correctly with invalid moment object 1`] = ` +exports[`Calendar render render correctly with invalid dayjs object 1`] = `
- - - - Mar - + title="Last year (Control + left)" + /> + - 2017 - - - - -
-
-
- - - - - - - - - - - - - + + + + + +
+
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - + - - Sa - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- 18 -
- -
- - - - - - - - - - - - - - - - - - - + + Su + + + + + + + + + + + - - - - - - - - - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
+
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
+ + Mo + + + + Tu + + + + We + + + + Th + + + + Fr + + + + Sa + +
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
diff --git a/tests/__snapshots__/FullCalendar.spec.js.snap b/tests/__snapshots__/FullCalendar.spec.js.snap index 69df28ea9..cdd760cd3 100644 --- a/tests/__snapshots__/FullCalendar.spec.js.snap +++ b/tests/__snapshots__/FullCalendar.spec.js.snap @@ -109,7 +109,7 @@ exports[`FullCalendar renders custom header correctly 1`] = `
Back to today @@ -1840,7 +1840,7 @@ exports[`RangeCalendar controlled panels render controlled panels correctly 1`]
Back to today @@ -3746,7 +3746,7 @@ exports[`RangeCalendar controlled panels render controlled panels correctly 2`]
Back to today @@ -5454,7 +5454,7 @@ exports[`RangeCalendar key control 1`] = `
Back to today @@ -6956,7 +6956,7 @@ exports[`RangeCalendar render hoverValue correctly 1`] = `
Back to today diff --git a/tests/__snapshots__/locale.spec.js.snap b/tests/__snapshots__/locale.spec.js.snap index aed844401..28f8811f7 100644 --- a/tests/__snapshots__/locale.spec.js.snap +++ b/tests/__snapshots__/locale.spec.js.snap @@ -29,740 +29,744 @@ exports[`locales renders ar_EG correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -798,740 +802,744 @@ exports[`locales renders bg_BG correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -1567,740 +1575,744 @@ exports[`locales renders ca_ES correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -2336,740 +2348,744 @@ exports[`locales renders cs_CZ correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -3105,740 +3121,744 @@ exports[`locales renders da_DK correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -3874,740 +3894,744 @@ exports[`locales renders de_DE correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -4643,740 +4667,744 @@ exports[`locales renders el_GR correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -5412,740 +5440,744 @@ exports[`locales renders en_GB correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -6181,740 +6213,744 @@ exports[`locales renders en_US correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -6950,740 +6986,744 @@ exports[`locales renders es_ES correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -7719,740 +7759,744 @@ exports[`locales renders et_EE correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -8488,740 +8532,744 @@ exports[`locales renders fa_IR correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -9257,740 +9305,744 @@ exports[`locales renders fi_FI correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -10026,740 +10078,744 @@ exports[`locales renders fr_BE correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -10795,740 +10851,744 @@ exports[`locales renders fr_FR correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -11564,740 +11624,744 @@ exports[`locales renders hu_HU correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -12333,740 +12397,744 @@ exports[`locales renders is_IS correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -13102,740 +13170,744 @@ exports[`locales renders it_IT correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -13871,740 +13943,744 @@ exports[`locales renders ja_JP correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -14640,740 +14716,744 @@ exports[`locales renders ko_KR correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -15409,740 +15489,744 @@ exports[`locales renders ku_IQ correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -16178,740 +16262,744 @@ exports[`locales renders nb_NO correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -16947,740 +17035,744 @@ exports[`locales renders nl_BE correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -17716,740 +17808,744 @@ exports[`locales renders nl_NL correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -18485,740 +18581,744 @@ exports[`locales renders pl_PL correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -19254,740 +19354,744 @@ exports[`locales renders pt_BR correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -20023,740 +20127,744 @@ exports[`locales renders pt_PT correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -20792,740 +20900,744 @@ exports[`locales renders ru_RU correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -21561,740 +21673,744 @@ exports[`locales renders sk_SK correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -22330,740 +22446,744 @@ exports[`locales renders sl_SI correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -23099,740 +23219,744 @@ exports[`locales renders sr_RS correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -23868,740 +23992,744 @@ exports[`locales renders sv_SE correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -24637,740 +24765,744 @@ exports[`locales renders th_TH correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -25406,740 +25538,744 @@ exports[`locales renders tr_TR correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -26175,740 +26311,744 @@ exports[`locales renders ug_CN correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -26944,740 +27084,744 @@ exports[`locales renders uk_UA correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -27713,740 +27857,744 @@ exports[`locales renders vi_VN correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -28482,740 +28630,744 @@ exports[`locales renders zh_CN correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
@@ -29251,740 +29403,744 @@ exports[`locales renders zh_TW correctly 1`] = `
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Su - - - - Mo - - - - Tu - - - - We - - - - Th - - - - Fr - - - - Sa - -
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- 9 -
-
-
- 10 -
-
-
- 11 -
-
-
- 12 -
-
-
- 13 -
-
-
- 14 -
-
-
- 15 -
-
-
- 16 -
-
-
- 17 -
-
-
- 18 -
-
-
- 19 -
-
-
- 20 -
-
-
- 21 -
-
-
- 22 -
-
-
- 23 -
-
-
- 24 -
-
-
- 25 -
-
-
- 26 -
-
-
- 27 -
-
-
- 28 -
-
-
- 29 -
-
-
- 30 -
-
-
- 31 -
-
-
- 1 -
-
-
- 2 -
-
-
- 3 -
-
-
- 4 -
-
-
- 5 -
-
-
- 6 -
-
-
- 7 -
-
-
- 8 -
-
-
- +
From a26aa3a4a12a9ae98720e6a6e64a90a7a9e83f0a Mon Sep 17 00:00:00 2001 From: zxj96 <519213124@qq.com> Date: Tue, 22 Feb 2022 14:17:56 +0800 Subject: [PATCH 20/41] fix: optimizated code --- examples/antd-calendar.js | 13 ++----------- examples/antd-month-calendar.js | 9 ++------- examples/antd-range-calendar.js | 11 +---------- examples/full-calendar.js | 10 +--------- examples/getCalendarContainer.js | 10 +--------- examples/start-end-range.js | 10 +--------- examples/start-end.js | 10 +--------- examples/week.js | 12 +----------- package.json | 2 +- src/util/dayjs.js | 17 +++++++++++++++++ tests/Calendar.spec.jsx | 17 +---------------- tests/FullCalendar.spec.js | 13 +------------ tests/MonthCalendar.spec.js | 13 +------------ tests/Picker.spec.jsx | 17 +---------------- tests/RangeCalendar.spec.jsx | 17 +---------------- 15 files changed, 33 insertions(+), 148 deletions(-) create mode 100644 src/util/dayjs.js diff --git a/examples/antd-calendar.js b/examples/antd-calendar.js index 5c29ac1a2..6170fefdb 100644 --- a/examples/antd-calendar.js +++ b/examples/antd-calendar.js @@ -10,19 +10,10 @@ import zhCN from '@seafile/seafile-calendar/src/locale/zh_CN'; import enUS from '@seafile/seafile-calendar/src/locale/en_US'; import 'rc-time-picker/assets/index.css'; import TimePickerPanel from 'rc-time-picker/lib/Panel'; - -import dayjs from 'dayjs'; -import 'dayjs/locale/zh-cn'; -import 'dayjs/locale/en-gb'; - -import localeData from 'dayjs/plugin/localeData'; -import utc from 'dayjs/plugin/utc'; +import dayjs from '../src/util/dayjs'; const format = 'YYYY-MM-DD HH:mm:ss'; -const cn = true; - -dayjs.extend(utc); -dayjs.extend(localeData); +const cn = location.search.indexOf('cn') !== -1; let now = dayjs(); if (cn) { diff --git a/examples/antd-month-calendar.js b/examples/antd-month-calendar.js index c4750674e..c67a79b6a 100644 --- a/examples/antd-month-calendar.js +++ b/examples/antd-month-calendar.js @@ -9,13 +9,8 @@ import DatePicker from '@seafile/seafile-calendar/src/Picker'; import zhCN from '@seafile/seafile-calendar/src/locale/zh_CN'; import enUS from '@seafile/seafile-calendar/src/locale/en_US'; -import dayjs from 'dayjs'; -import localeData from 'dayjs/plugin/localeData'; -import utc from 'dayjs/plugin/utc'; -import 'dayjs/locale/zh-cn'; -import 'dayjs/locale/en-gb'; -dayjs.extend(utc); -dayjs.extend(localeData); + +import dayjs from '../src/util/dayjs'; const format = 'YYYY-MM'; const cn = location.search.indexOf('cn') !== -1; diff --git a/examples/antd-range-calendar.js b/examples/antd-range-calendar.js index bf119322e..0fb941936 100644 --- a/examples/antd-range-calendar.js +++ b/examples/antd-range-calendar.js @@ -10,16 +10,7 @@ import TimePickerPanel from 'rc-time-picker/lib/Panel'; import '@seafile/seafile-calendar/assets/index.less'; import 'rc-time-picker/assets/index.css'; -import dayjs from 'dayjs'; -import localeData from 'dayjs/plugin/localeData'; -import utc from 'dayjs/plugin/utc'; -import weekOfYear from 'dayjs/plugin/weekOfYear'; -import 'dayjs/locale/zh-cn'; -import 'dayjs/locale/en-gb'; -dayjs.extend(utc); -dayjs.extend(localeData); -dayjs.extend(weekOfYear); - +import dayjs from '../src/util/dayjs'; const cn = location.search.indexOf('cn') !== -1; diff --git a/examples/full-calendar.js b/examples/full-calendar.js index 2847d2f91..3761a353f 100644 --- a/examples/full-calendar.js +++ b/examples/full-calendar.js @@ -11,15 +11,7 @@ import Select from 'rc-select'; import zhCN from '@seafile/seafile-calendar/src/locale/zh_CN'; import enUS from '@seafile/seafile-calendar/src/locale/en_US'; -import dayjs from 'dayjs'; -import localeData from 'dayjs/plugin/localeData'; -import utc from 'dayjs/plugin/utc'; -import weekOfYear from 'dayjs/plugin/weekOfYear'; -import 'dayjs/locale/zh-cn'; -import 'dayjs/locale/en-gb'; -dayjs.extend(utc); -dayjs.extend(localeData); -dayjs.extend(weekOfYear); +import dayjs from '../src/util/dayjs'; const format = 'YYYY-MM-DD'; const cn = location.search.indexOf('cn') !== -1; diff --git a/examples/getCalendarContainer.js b/examples/getCalendarContainer.js index 9ed981c4b..c8148961d 100644 --- a/examples/getCalendarContainer.js +++ b/examples/getCalendarContainer.js @@ -9,15 +9,7 @@ import 'rc-dialog/assets/index.css'; import zhCN from '@seafile/seafile-calendar/src/locale/zh_CN'; import enUS from '@seafile/seafile-calendar/src/locale/en_US'; -import dayjs from 'dayjs'; -import localeData from 'dayjs/plugin/localeData'; -import utc from 'dayjs/plugin/utc'; -import weekOfYear from 'dayjs/plugin/weekOfYear'; -import 'dayjs/locale/zh-cn'; -import 'dayjs/locale/en-gb'; -dayjs.extend(utc); -dayjs.extend(localeData); -dayjs.extend(weekOfYear); +import dayjs from '../src/util/dayjs'; const format = 'YYYY-MM-DD'; const cn = location.search.indexOf('cn') !== -1; diff --git a/examples/start-end-range.js b/examples/start-end-range.js index 0c495e8c0..244c9b50a 100644 --- a/examples/start-end-range.js +++ b/examples/start-end-range.js @@ -9,15 +9,7 @@ import DatePicker from '@seafile/seafile-calendar/src/Picker'; import zhCN from '@seafile/seafile-calendar/src/locale/zh_CN'; import enUS from '@seafile/seafile-calendar/src/locale/en_US'; -import dayjs from 'dayjs'; -import localeData from 'dayjs/plugin/localeData'; -import utc from 'dayjs/plugin/utc'; -import weekOfYear from 'dayjs/plugin/weekOfYear'; -import 'dayjs/locale/zh-cn'; -import 'dayjs/locale/en-gb'; -dayjs.extend(utc); -dayjs.extend(localeData); -dayjs.extend(weekOfYear); +import dayjs from '../src/util/dayjs'; const format = 'YYYY-MM-DD'; diff --git a/examples/start-end.js b/examples/start-end.js index 2226d6b27..a09423e12 100644 --- a/examples/start-end.js +++ b/examples/start-end.js @@ -11,15 +11,7 @@ import enUS from '@seafile/seafile-calendar/src/locale/en_US'; import 'rc-time-picker/assets/index.css'; import TimePickerPanel from 'rc-time-picker/lib/Panel'; -import dayjs from 'dayjs'; -import localeData from 'dayjs/plugin/localeData'; -import utc from 'dayjs/plugin/utc'; -import weekOfYear from 'dayjs/plugin/weekOfYear'; -import 'dayjs/locale/zh-cn'; -import 'dayjs/locale/en-gb'; -dayjs.extend(utc); -dayjs.extend(localeData); -dayjs.extend(weekOfYear); +import dayjs from '../src/util/dayjs'; const format = 'YYYY-MM-DD HH:mm:ss'; const cn = location.search.indexOf('cn') !== -1; diff --git a/examples/week.js b/examples/week.js index 6138fefe0..538a39b2b 100644 --- a/examples/week.js +++ b/examples/week.js @@ -9,17 +9,7 @@ import DatePicker from '@seafile/seafile-calendar/src/Picker'; import zhCN from '@seafile/seafile-calendar/src/locale/zh_CN'; import enUS from '@seafile/seafile-calendar/src/locale/en_US'; -import dayjs from 'dayjs'; -import localeData from 'dayjs/plugin/localeData'; -import utc from 'dayjs/plugin/utc'; -import weekOfYear from 'dayjs/plugin/weekOfYear'; -import advancedFormat from 'dayjs/plugin/advancedFormat'; -import 'dayjs/locale/zh-cn'; -import 'dayjs/locale/en-gb'; -dayjs.extend(utc); -dayjs.extend(localeData); -dayjs.extend(weekOfYear); -dayjs.extend(advancedFormat); +import dayjs from '../src/util/dayjs'; const format = 'YYYY-wo'; const cn = location.search.indexOf('cn') !== -1; diff --git a/package.json b/package.json index bd5ff17c3..052de4636 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@seafile/seafile-calendar", - "version": "0.0.16", + "version": "0.0.18", "description": "React Calendar", "keywords": [ "react", diff --git a/src/util/dayjs.js b/src/util/dayjs.js new file mode 100644 index 000000000..46eebcbe6 --- /dev/null +++ b/src/util/dayjs.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs'; +import localeData from 'dayjs/plugin/localeData'; +import weekOfYear from 'dayjs/plugin/weekOfYear'; +import utc from 'dayjs/plugin/utc'; +import advancedFormat from 'dayjs/plugin/advancedFormat'; +import customParseFormat from 'dayjs/plugin/customParseFormat'; +import badMutable from 'dayjs/plugin/badMutable'; +import 'dayjs/locale/zh-cn'; +import 'dayjs/locale/en-gb'; + +dayjs.extend(localeData); +dayjs.extend(weekOfYear); +dayjs.extend(utc); +dayjs.extend(advancedFormat); +dayjs.extend(customParseFormat); +dayjs.extend(badMutable); +export default dayjs; diff --git a/tests/Calendar.spec.jsx b/tests/Calendar.spec.jsx index 01fd5f79a..31ccee411 100644 --- a/tests/Calendar.spec.jsx +++ b/tests/Calendar.spec.jsx @@ -1,28 +1,13 @@ /* eslint-disable no-undef */ import React from 'react'; import keyCode from 'rc-util/lib/KeyCode'; -import dayjs from 'dayjs'; +import dayjs from '../src/util/dayjs'; import { mount, render } from 'enzyme'; import TimePickerPanel from 'rc-time-picker/lib/Panel'; import Calendar from '../src/Calendar'; import zhCN from '../src/locale/zh_CN'; import enUS from '../src/locale/en_US'; -import localeData from 'dayjs/plugin/localeData'; -import utc from 'dayjs/plugin/utc'; -import weekOfYear from 'dayjs/plugin/weekOfYear'; -import advancedFormat from 'dayjs/plugin/advancedFormat'; -import customParseFormat from 'dayjs/plugin/customParseFormat'; -import badMutable from 'dayjs/plugin/badMutable'; -import 'dayjs/locale/zh-cn'; -import 'dayjs/locale/en-gb'; -dayjs.extend(utc); -dayjs.extend(localeData); -dayjs.extend(weekOfYear); -dayjs.extend(advancedFormat); -dayjs.extend(customParseFormat); -dayjs.extend(badMutable); - const format = ('YYYY-MM-DD'); describe('Calendar', () => { diff --git a/tests/FullCalendar.spec.js b/tests/FullCalendar.spec.js index 4caf9e560..8d722b995 100644 --- a/tests/FullCalendar.spec.js +++ b/tests/FullCalendar.spec.js @@ -2,20 +2,9 @@ import React from 'react'; import Select from 'rc-select'; import { render, mount } from 'enzyme'; -import dayjs from 'dayjs'; +import dayjs from '../src/util/dayjs'; import FullCalendar from '../src/FullCalendar'; -import localeData from 'dayjs/plugin/localeData'; -import utc from 'dayjs/plugin/utc'; -import weekOfYear from 'dayjs/plugin/weekOfYear'; -import advancedFormat from 'dayjs/plugin/advancedFormat'; -import 'dayjs/locale/zh-cn'; -import 'dayjs/locale/en-gb'; -dayjs.extend(utc); -dayjs.extend(localeData); -dayjs.extend(weekOfYear); -dayjs.extend(advancedFormat); - describe('FullCalendar', () => { it('renders month mode correctly', () => { const wrapper = render( diff --git a/tests/MonthCalendar.spec.js b/tests/MonthCalendar.spec.js index e5b0d0ad3..83a95e6e3 100644 --- a/tests/MonthCalendar.spec.js +++ b/tests/MonthCalendar.spec.js @@ -2,19 +2,8 @@ import React from 'react'; import { mount } from 'enzyme'; import keyCode from 'rc-util/lib/KeyCode'; -import dayjs from 'dayjs'; import MonthCalendar from '../src/MonthCalendar'; - -import localeData from 'dayjs/plugin/localeData'; -import utc from 'dayjs/plugin/utc'; -import weekOfYear from 'dayjs/plugin/weekOfYear'; -import advancedFormat from 'dayjs/plugin/advancedFormat'; -import 'dayjs/locale/zh-cn'; -import 'dayjs/locale/en-gb'; -dayjs.extend(utc); -dayjs.extend(localeData); -dayjs.extend(weekOfYear); -dayjs.extend(advancedFormat); +import dayjs from '../src/util/dayjs'; describe('MonthCalendar', () => { it('year or decade panel work correctly', () => { diff --git a/tests/Picker.spec.jsx b/tests/Picker.spec.jsx index 0476e9c9f..1a7bb0397 100644 --- a/tests/Picker.spec.jsx +++ b/tests/Picker.spec.jsx @@ -1,26 +1,11 @@ import React from 'react'; -import dayjs from 'dayjs'; import { mount } from 'enzyme'; import keyCode from 'rc-util/lib/KeyCode'; import Calendar from '../index'; import DatePicker from '../src/Picker'; import RangeCalendar from '../src/RangeCalendar'; import CalendarLocale from '../src/locale/en_US'; - -import localeData from 'dayjs/plugin/localeData'; -import utc from 'dayjs/plugin/utc'; -import weekOfYear from 'dayjs/plugin/weekOfYear'; -import advancedFormat from 'dayjs/plugin/advancedFormat'; -import customParseFormat from 'dayjs/plugin/customParseFormat'; -import badMutable from 'dayjs/plugin/badMutable'; -import 'dayjs/locale/zh-cn'; -import 'dayjs/locale/en-gb'; -dayjs.extend(utc); -dayjs.extend(localeData); -dayjs.extend(weekOfYear); -dayjs.extend(advancedFormat); -dayjs.extend(customParseFormat); -dayjs.extend(badMutable); +import dayjs from '../src/util/dayjs'; const format = ('YYYY-MM-DD'); const VALUE = dayjs([2015, 5, 1]); diff --git a/tests/RangeCalendar.spec.jsx b/tests/RangeCalendar.spec.jsx index c3f2fd270..05de0b492 100644 --- a/tests/RangeCalendar.spec.jsx +++ b/tests/RangeCalendar.spec.jsx @@ -1,25 +1,10 @@ /* eslint-disable no-undef, max-len, react/no-multi-comp */ import React from 'react'; -import dayjs from 'dayjs'; import { mount, render } from 'enzyme'; import keyCode from 'rc-util/lib/KeyCode'; import TimePickerPanel from 'rc-time-picker/lib/Panel'; import RangeCalendar from '../src/RangeCalendar'; - -import localeData from 'dayjs/plugin/localeData'; -import utc from 'dayjs/plugin/utc'; -import weekOfYear from 'dayjs/plugin/weekOfYear'; -import advancedFormat from 'dayjs/plugin/advancedFormat'; -import customParseFormat from 'dayjs/plugin/customParseFormat'; -import badMutable from 'dayjs/plugin/badMutable'; -import 'dayjs/locale/zh-cn'; -import 'dayjs/locale/en-gb'; -dayjs.extend(utc); -dayjs.extend(localeData); -dayjs.extend(weekOfYear); -dayjs.extend(advancedFormat); -dayjs.extend(customParseFormat); -dayjs.extend(badMutable); +import dayjs from '../src/util/dayjs'; const format = ('YYYY-MM-DD'); From 170da48c5b41614f8833aa4932b44115b81c7425 Mon Sep 17 00:00:00 2001 From: zxj96 <519213124@qq.com> Date: Wed, 2 Mar 2022 15:46:29 +0800 Subject: [PATCH 21/41] fix: caldaner width bug --- assets/index/Calendar.less | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/index/Calendar.less b/assets/index/Calendar.less index 1d3fd3312..8b6a096bc 100644 --- a/assets/index/Calendar.less +++ b/assets/index/Calendar.less @@ -2,7 +2,7 @@ position: relative; outline: none; font-family: Arial, "Hiragino Sans GB", "Microsoft Yahei", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans-serif; - width: 253px; + width: fit-content; border: 1px solid #ccc; list-style: none; font-size: 12px; diff --git a/package.json b/package.json index 052de4636..1a1e49bed 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@seafile/seafile-calendar", - "version": "0.0.18", + "version": "0.0.19", "description": "React Calendar", "keywords": [ "react", From c6b8e99402628212603d5906dfcdeea8a0284e05 Mon Sep 17 00:00:00 2001 From: zxj96 <519213124@qq.com> Date: Wed, 20 Apr 2022 15:17:43 +0800 Subject: [PATCH 22/41] fix: dayjs does not introduce the loaneData plugin --- package.json | 2 +- src/FullCalendar.jsx | 2 +- src/MonthCalendar.jsx | 2 +- src/RangeCalendar.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 1a1e49bed..2e2f6b3cd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@seafile/seafile-calendar", - "version": "0.0.19", + "version": "0.0.21", "description": "React Calendar", "keywords": [ "react", diff --git a/src/FullCalendar.jsx b/src/FullCalendar.jsx index 4a8cb19dc..4745406e9 100644 --- a/src/FullCalendar.jsx +++ b/src/FullCalendar.jsx @@ -11,7 +11,7 @@ import { } from './mixin/CalendarMixin'; import { commonMixinWrapper, propType, defaultProp } from './mixin/CommonMixin'; import CalendarHeader from './full-calendar/CalendarHeader'; -import dayjs from 'dayjs'; +import dayjs from './util/dayjs'; class FullCalendar extends React.Component { static propTypes = { diff --git a/src/MonthCalendar.jsx b/src/MonthCalendar.jsx index bbee730ef..f2010ae36 100644 --- a/src/MonthCalendar.jsx +++ b/src/MonthCalendar.jsx @@ -10,7 +10,7 @@ import { calendarMixinDefaultProps, } from './mixin/CalendarMixin'; import { commonMixinWrapper, propType, defaultProp } from './mixin/CommonMixin'; -import dayjs from 'dayjs'; +import dayjs from './util/dayjs'; class MonthCalendar extends React.Component { static propTypes = { diff --git a/src/RangeCalendar.js b/src/RangeCalendar.js index 9b5deb8ce..6783b590c 100644 --- a/src/RangeCalendar.js +++ b/src/RangeCalendar.js @@ -1,6 +1,5 @@ import React from 'react'; import PropTypes from 'prop-types'; -import dayjs from 'dayjs'; import classnames from 'classnames'; import { polyfill } from 'react-lifecycles-compat'; import KeyCode from 'rc-util/lib/KeyCode'; @@ -11,6 +10,7 @@ import TimePickerButton from './calendar/TimePickerButton'; import { commonMixinWrapper, propType, defaultProp } from './mixin/CommonMixin'; import { syncTime, getTodayTime, isAllowedDate } from './util'; import { goTime, goStartMonth, goEndMonth, includesTime } from './util/toTime'; +import dayjs from './util/dayjs'; function noop() { } From 90c0a842ae2b812837673b3d97a1eddb781559d5 Mon Sep 17 00:00:00 2001 From: Michael An <1822852997@qq.com> Date: Thu, 8 Sep 2022 14:14:45 +0800 Subject: [PATCH 23/41] change click first or last year --- assets/index/YearPanel.less | 8 -------- package.json | 2 +- src/year/YearPanel.jsx | 12 +----------- tests/__snapshots__/Calendar.spec.jsx.snap | 4 ++-- tests/__snapshots__/RangeCalendar.spec.jsx.snap | 8 ++++---- 5 files changed, 8 insertions(+), 26 deletions(-) diff --git a/assets/index/YearPanel.less b/assets/index/YearPanel.less index cbdb0fc3d..96ed4d39d 100644 --- a/assets/index/YearPanel.less +++ b/assets/index/YearPanel.less @@ -124,11 +124,3 @@ color: #fff; } } - -.@{prefixClass}-year-panel-last-decade-cell, .@{prefixClass}-year-panel-next-decade-cell { - .@{prefixClass}-year-panel-year{ - user-select: none; - -webkit-user-select: none; - color: rgba(0, 0, 0, 0.25); - } -} \ No newline at end of file diff --git a/package.json b/package.json index 2e2f6b3cd..9ea185d68 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@seafile/seafile-calendar", - "version": "0.0.21", + "version": "0.0.22", "description": "React Calendar", "keywords": [ "react", diff --git a/src/year/YearPanel.jsx b/src/year/YearPanel.jsx index 48dbb67a8..b0d4acaf6 100644 --- a/src/year/YearPanel.jsx +++ b/src/year/YearPanel.jsx @@ -70,23 +70,13 @@ export default class YearPanel extends React.Component { const classNameMap = { [`${prefixCls}-cell`]: 1, [`${prefixCls}-selected-cell`]: yearData.year === currentYear, - [`${prefixCls}-last-decade-cell`]: yearData.year < startYear, - [`${prefixCls}-next-decade-cell`]: yearData.year > endYear, }; - let clickHandler; - if (yearData.year < startYear) { - clickHandler = this.previousDecade; - } else if (yearData.year > endYear) { - clickHandler = this.nextDecade; - } else { - clickHandler = chooseYear.bind(this, yearData.year); - } return ( @@ -1231,7 +1231,7 @@ exports[`Calendar controlled panels render controlled panels correctly 2`] = ` diff --git a/tests/__snapshots__/RangeCalendar.spec.jsx.snap b/tests/__snapshots__/RangeCalendar.spec.jsx.snap index 1b6910b9e..12d74df43 100644 --- a/tests/__snapshots__/RangeCalendar.spec.jsx.snap +++ b/tests/__snapshots__/RangeCalendar.spec.jsx.snap @@ -3495,7 +3495,7 @@ exports[`RangeCalendar controlled panels render controlled panels correctly 2`] role="row" > @@ -3628,7 +3628,7 @@ exports[`RangeCalendar controlled panels render controlled panels correctly 2`] @@ -4435,7 +4435,7 @@ exports[`RangeCalendar controlled panels render controlled panels correctly 2`] role="row" > @@ -4568,7 +4568,7 @@ exports[`RangeCalendar controlled panels render controlled panels correctly 2`] From a1d40aeb6b730d54c2104d835ed7768934ff040a Mon Sep 17 00:00:00 2001 From: Michael An <1822852997@qq.com> Date: Tue, 13 Sep 2022 10:09:33 +0800 Subject: [PATCH 24/41] update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9ea185d68..4e3504173 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@seafile/seafile-calendar", - "version": "0.0.22", + "version": "0.0.24", "description": "React Calendar", "keywords": [ "react", From bd295da9b5d97533df18f38e1600c37cd11177f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=9B=BD=E7=92=87?= Date: Wed, 18 Sep 2024 10:53:41 +0800 Subject: [PATCH 25/41] feat: time second --- README.md | 3 +++ package.json | 2 +- src/Calendar.jsx | 14 +++++++------ src/calendar/CalendarRightPanel.jsx | 32 +++++++++++++++++++++-------- 4 files changed, 36 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 6cc73412a..e134ae6ec 100644 --- a/README.md +++ b/README.md @@ -756,3 +756,6 @@ open coverage/ dir ## License rc-calendar is released under the MIT license. + +# node version +18.20.4 diff --git a/package.json b/package.json index 4e3504173..a2c66406c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@seafile/seafile-calendar", - "version": "0.0.24", + "version": "0.0.25", "description": "React Calendar", "keywords": [ "react", diff --git a/src/Calendar.jsx b/src/Calendar.jsx index dbe76d353..6b52dca17 100644 --- a/src/Calendar.jsx +++ b/src/Calendar.jsx @@ -53,7 +53,8 @@ class Calendar extends React.Component { showToday: PropTypes.bool, showOk: PropTypes.bool, showHourAndMinute: PropTypes.bool, - defaultMinutesTime: PropTypes.string, + showSecond: PropTypes.bool, + defaultTime: PropTypes.string, onSelect: PropTypes.func, onOk: PropTypes.func, onKeyDown: PropTypes.func, @@ -284,9 +285,9 @@ class Calendar extends React.Component { render() { const { props, state } = this; const { - locale, prefixCls, disabledDate, + locale, prefixCls, disabledDate, showSecond, showHourAndMinute, dateInputPlaceholder, timePicker, onClickRightPanelTime, - disabledTime, clearIcon, renderFooter, inputMode, showHourAndMinute, + disabledTime, clearIcon, renderFooter, inputMode, defaultTime, } = props; const { value, selectedValue, mode } = state; const showTimePicker = mode === 'time'; @@ -399,16 +400,17 @@ class Calendar extends React.Component { onCloseTimePicker={this.closeTimePicker} />
- {showHourAndMinute && + {(showHourAndMinute || showSecond) && ( - } + )}
); diff --git a/src/calendar/CalendarRightPanel.jsx b/src/calendar/CalendarRightPanel.jsx index 8497b5eaf..dfbe55760 100644 --- a/src/calendar/CalendarRightPanel.jsx +++ b/src/calendar/CalendarRightPanel.jsx @@ -5,12 +5,13 @@ import dayjs from 'dayjs'; export default class CalendarRightPanel extends React.Component { static propTypes = { + showSecond: PropTypes.bool, prefixCls: PropTypes.string, value: PropTypes.object, + locale: PropTypes.object, + defaultTime: PropTypes.string, onSelect: PropTypes.func, onClickRightPanelTime: PropTypes.func, - locale: PropTypes.object, - defaultMinutesTime: PropTypes.string, } constructor(props) { @@ -23,8 +24,8 @@ export default class CalendarRightPanel extends React.Component { } componentDidMount() { - const { defaultMinutesTime } = this.props; - const showTimeIndex = this.times.findIndex(item => item === defaultMinutesTime); + const { defaultTime } = this.props; + const showTimeIndex = defaultTime ? this.times.findIndex(item => item >= defaultTime) : -1; const scrollTimeIndex = showTimeIndex > -1 ? showTimeIndex : 16; this.timeRef.current.scrollTo(0, 34 * scrollTimeIndex); } @@ -38,12 +39,27 @@ export default class CalendarRightPanel extends React.Component { } getTimes = () => { + const { showSecond } = this.props; const times = []; for (let i = 0; i < 24; i++) { - const str = (`${String(i)}:00`).padStart(5, '0'); - const str1 = (`${String(i)}:30`).padStart(5, '0'); - times.push(str); - times.push(str1); + const minute0 = (`${String(i)}:00`).padStart(5, '0'); + if (showSecond) { + const second0 = `${minute0}:00`; + const second30 = `${minute0}:30`; + times.push(second0); + times.push(second30); + } else { + times.push(minute0); + } + const minute30 = (`${String(i)}:30`).padStart(5, '0'); + if (showSecond) { + const second0 = `${minute30}:00`; + const second30 = `${minute30}:30`; + times.push(second0); + times.push(second30); + } else { + times.push(minute30); + } } return times; } From 3104a71b2d2171c3d7df11fb9757202fcc087ffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=9B=BD=E7=92=87?= Date: Wed, 18 Sep 2024 11:22:34 +0800 Subject: [PATCH 26/41] feat: update code --- src/Calendar.jsx | 6 ++---- src/calendar/CalendarRightPanel.jsx | 20 ++------------------ 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/src/Calendar.jsx b/src/Calendar.jsx index 6b52dca17..7f91fb764 100644 --- a/src/Calendar.jsx +++ b/src/Calendar.jsx @@ -53,7 +53,6 @@ class Calendar extends React.Component { showToday: PropTypes.bool, showOk: PropTypes.bool, showHourAndMinute: PropTypes.bool, - showSecond: PropTypes.bool, defaultTime: PropTypes.string, onSelect: PropTypes.func, onOk: PropTypes.func, @@ -285,7 +284,7 @@ class Calendar extends React.Component { render() { const { props, state } = this; const { - locale, prefixCls, disabledDate, showSecond, showHourAndMinute, + locale, prefixCls, disabledDate, showHourAndMinute, dateInputPlaceholder, timePicker, onClickRightPanelTime, disabledTime, clearIcon, renderFooter, inputMode, defaultTime, } = props; @@ -400,9 +399,8 @@ class Calendar extends React.Component { onCloseTimePicker={this.closeTimePicker} />
- {(showHourAndMinute || showSecond) && ( + {(showHourAndMinute) && ( { - const { showSecond } = this.props; const times = []; for (let i = 0; i < 24; i++) { const minute0 = (`${String(i)}:00`).padStart(5, '0'); - if (showSecond) { - const second0 = `${minute0}:00`; - const second30 = `${minute0}:30`; - times.push(second0); - times.push(second30); - } else { - times.push(minute0); - } + times.push(minute0); const minute30 = (`${String(i)}:30`).padStart(5, '0'); - if (showSecond) { - const second0 = `${minute30}:00`; - const second30 = `${minute30}:30`; - times.push(second0); - times.push(second30); - } else { - times.push(minute30); - } + times.push(minute30); } return times; } From f573335b18bdbc984b1707eaf8474ef7d5b51b7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=9B=BD=E7=92=87?= Date: Wed, 18 Sep 2024 15:21:52 +0800 Subject: [PATCH 27/41] feat: update code --- package.json | 7 +++++-- src/calendar/CalendarRightPanel.jsx | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index a2c66406c..3b886282a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@seafile/seafile-calendar", - "version": "0.0.25", + "version": "0.0.27", "description": "React Calendar", "keywords": [ "react", @@ -97,5 +97,8 @@ "rc-util": "^4.1.1", "react-lifecycles-compat": "^3.0.4" }, - "types": "index.d.ts" + "types": "index.d.ts", + "overrides": { + "graceful-fs": "^4.2.11" + } } diff --git a/src/calendar/CalendarRightPanel.jsx b/src/calendar/CalendarRightPanel.jsx index 8423aa543..7e814a7de 100644 --- a/src/calendar/CalendarRightPanel.jsx +++ b/src/calendar/CalendarRightPanel.jsx @@ -29,12 +29,12 @@ export default class CalendarRightPanel extends React.Component { this.timeRef.current.scrollTo(0, 34 * scrollTimeIndex); } - onSelect = (value) => { + onSelect = (value, event) => { this.setState({ highlightTime: value, }); this.props.onSelect(value); - this.props.onClickRightPanelTime(); + this.props.onClickRightPanelTime(event); } getTimes = () => { From 6281a2987237708328d8763c8dd7445670b9b51d Mon Sep 17 00:00:00 2001 From: er-pai-r <18335219360@163.com> Date: Wed, 18 Sep 2024 22:30:41 +0800 Subject: [PATCH 28/41] feat: update code --- package.json | 2 +- src/Calendar.jsx | 12 ++++++------ src/calendar/CalendarRightPanel.jsx | 18 +++++++++--------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 3b886282a..cc95dd161 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@seafile/seafile-calendar", - "version": "0.0.27", + "version": "0.0.28", "description": "React Calendar", "keywords": [ "react", diff --git a/src/Calendar.jsx b/src/Calendar.jsx index 7f91fb764..dbe76d353 100644 --- a/src/Calendar.jsx +++ b/src/Calendar.jsx @@ -53,7 +53,7 @@ class Calendar extends React.Component { showToday: PropTypes.bool, showOk: PropTypes.bool, showHourAndMinute: PropTypes.bool, - defaultTime: PropTypes.string, + defaultMinutesTime: PropTypes.string, onSelect: PropTypes.func, onOk: PropTypes.func, onKeyDown: PropTypes.func, @@ -284,9 +284,9 @@ class Calendar extends React.Component { render() { const { props, state } = this; const { - locale, prefixCls, disabledDate, showHourAndMinute, + locale, prefixCls, disabledDate, dateInputPlaceholder, timePicker, onClickRightPanelTime, - disabledTime, clearIcon, renderFooter, inputMode, defaultTime, + disabledTime, clearIcon, renderFooter, inputMode, showHourAndMinute, } = props; const { value, selectedValue, mode } = state; const showTimePicker = mode === 'time'; @@ -399,16 +399,16 @@ class Calendar extends React.Component { onCloseTimePicker={this.closeTimePicker} />
- {(showHourAndMinute) && ( + {showHourAndMinute && - )} + }
); diff --git a/src/calendar/CalendarRightPanel.jsx b/src/calendar/CalendarRightPanel.jsx index 7e814a7de..637dc6693 100644 --- a/src/calendar/CalendarRightPanel.jsx +++ b/src/calendar/CalendarRightPanel.jsx @@ -7,10 +7,10 @@ export default class CalendarRightPanel extends React.Component { static propTypes = { prefixCls: PropTypes.string, value: PropTypes.object, - locale: PropTypes.object, - defaultTime: PropTypes.string, onSelect: PropTypes.func, onClickRightPanelTime: PropTypes.func, + locale: PropTypes.object, + defaultMinutesTime: PropTypes.string, } constructor(props) { @@ -23,9 +23,9 @@ export default class CalendarRightPanel extends React.Component { } componentDidMount() { - const { defaultTime } = this.props; - const showTimeIndex = defaultTime ? this.times.findIndex(item => item >= defaultTime) : -1; - const scrollTimeIndex = showTimeIndex > -1 ? showTimeIndex : 16; + const { defaultMinutesTime } = this.props; + const showTimeIndex = this.times.findIndex(item => item >= defaultMinutesTime); + const scrollTimeIndex = showTimeIndex > -1 ? showTimeIndex - 1 : 16; this.timeRef.current.scrollTo(0, 34 * scrollTimeIndex); } @@ -40,10 +40,10 @@ export default class CalendarRightPanel extends React.Component { getTimes = () => { const times = []; for (let i = 0; i < 24; i++) { - const minute0 = (`${String(i)}:00`).padStart(5, '0'); - times.push(minute0); - const minute30 = (`${String(i)}:30`).padStart(5, '0'); - times.push(minute30); + const str = (`${String(i)}:00`).padStart(5, '0'); + const str1 = (`${String(i)}:30`).padStart(5, '0'); + times.push(str); + times.push(str1); } return times; } From 9650d96a85e796e51e549977fb7ed37137a31fd7 Mon Sep 17 00:00:00 2001 From: er-pai-r <18335219360@163.com> Date: Wed, 18 Sep 2024 22:35:20 +0800 Subject: [PATCH 29/41] feat: update code --- src/calendar/CalendarRightPanel.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calendar/CalendarRightPanel.jsx b/src/calendar/CalendarRightPanel.jsx index 637dc6693..861378753 100644 --- a/src/calendar/CalendarRightPanel.jsx +++ b/src/calendar/CalendarRightPanel.jsx @@ -29,12 +29,12 @@ export default class CalendarRightPanel extends React.Component { this.timeRef.current.scrollTo(0, 34 * scrollTimeIndex); } - onSelect = (value, event) => { + onSelect = (value) => { this.setState({ highlightTime: value, }); this.props.onSelect(value); - this.props.onClickRightPanelTime(event); + this.props.onClickRightPanelTime(); } getTimes = () => { From 1fbc075e67f29884e41824b6b638d8c31ad2ee19 Mon Sep 17 00:00:00 2001 From: er-pai-r <18335219360@163.com> Date: Wed, 18 Sep 2024 23:32:28 +0800 Subject: [PATCH 30/41] feat: update version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e134ae6ec..7b4bbfb01 100644 --- a/README.md +++ b/README.md @@ -758,4 +758,4 @@ open coverage/ dir rc-calendar is released under the MIT license. # node version -18.20.4 +>= 18.20.4 From 4320e200fb9b04856916767f73f10a1043aad57b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=8E=89=E9=91=AB?= Date: Tue, 1 Apr 2025 15:19:09 +0800 Subject: [PATCH 31/41] support customizing the first day of week --- src/Calendar.jsx | 6 ++++-- src/date/DateConstants.js | 17 ++++++++++++++++- src/date/DateTBody.jsx | 22 ++++++++++++---------- src/date/DateTHead.jsx | 32 +++++++++++++++++++------------- 4 files changed, 51 insertions(+), 26 deletions(-) diff --git a/src/Calendar.jsx b/src/Calendar.jsx index dbe76d353..17645fca9 100644 --- a/src/Calendar.jsx +++ b/src/Calendar.jsx @@ -85,6 +85,7 @@ class Calendar extends React.Component { onPanelChange: noop, onClickRightPanelTime: noop, focusablePanel: true, + firstDayOfWeek: 'Sunday', } constructor(props) { @@ -286,7 +287,7 @@ class Calendar extends React.Component { const { locale, prefixCls, disabledDate, dateInputPlaceholder, timePicker, onClickRightPanelTime, - disabledTime, clearIcon, renderFooter, inputMode, showHourAndMinute, + disabledTime, clearIcon, renderFooter, inputMode, showHourAndMinute, firstDayOfWeek, showWeekNumber } = props; const { value, selectedValue, mode } = state; const showTimePicker = mode === 'time'; @@ -371,7 +372,8 @@ class Calendar extends React.Component { dateRender={props.dateRender} onSelect={this.onDateTableSelect} disabledDate={disabledDate} - showWeekNumber={props.showWeekNumber} + showWeekNumber={showWeekNumber} + firstDayOfWeek={firstDayOfWeek} />
diff --git a/src/date/DateConstants.js b/src/date/DateConstants.js index 55f910b00..439228b70 100644 --- a/src/date/DateConstants.js +++ b/src/date/DateConstants.js @@ -1,4 +1,19 @@ -export default { +const DATE_ROW_COLUMN_COUNT = { DATE_ROW_COUNT: 6, DATE_COL_COUNT: 7, }; + +const DAY_NAME_TO_INDEX = { + Sunday: 0, + Monday: 1, + Tuesday: 2, + Wednesday: 3, + Thursday: 4, + Friday: 5, + Saturday: 6, +}; + +export default { + DATE_ROW_COLUMN_COUNT, + DAY_NAME_TO_INDEX +}; diff --git a/src/date/DateTBody.jsx b/src/date/DateTBody.jsx index 0c356ec6b..5ad7e3060 100644 --- a/src/date/DateTBody.jsx +++ b/src/date/DateTBody.jsx @@ -4,6 +4,8 @@ import cx from 'classnames'; import DateConstants from './DateConstants'; import { getTitleString, getTodayTime } from '../util/'; +const { DATE_ROW_COLUMN_COUNT, DAY_NAME_TO_INDEX } = DateConstants; + function isSameDay(one, two) { return one && two && one.isSame(two, 'day'); } @@ -38,6 +40,7 @@ export default class DateTBody extends React.Component { value: PropTypes.object, hoverValue: PropTypes.any, showWeekNumber: PropTypes.bool, + firstDayOfWeek: PropTypes.string, } static defaultProps = { @@ -49,7 +52,7 @@ export default class DateTBody extends React.Component { const { contentRender, prefixCls, selectedValue, value, showWeekNumber, dateRender, disabledDate, - hoverValue, + hoverValue, firstDayOfWeek, } = props; let iIndex; let jIndex; @@ -74,17 +77,16 @@ export default class DateTBody extends React.Component { let month1 = value.clone(); month1 = month1.date(1); const day = month1.day(); - // const firstDayOfWeek = value.localeData().firstDayOfWeek(); - // We set Sunday(7) as the first day of the week in seafile-calendar. - const firstDayOfWeek = 7; - const lastMonthDiffDay = (day + 7 - firstDayOfWeek) % 7; + const firstDayName = typeof firstDayOfWeek === 'string' ? firstDayOfWeek[0].toUpperCase() + firstDayOfWeek.slice(1) : 'Sunday'; + const firstDayIndex = DAY_NAME_TO_INDEX[firstDayName] ? DAY_NAME_TO_INDEX[firstDayName] : 0; + const lastMonthDiffDay = (day + 7 - firstDayIndex) % 7; // calculate last month let lastMonth1 = month1.clone(); lastMonth1 = lastMonth1.add(0 - lastMonthDiffDay, 'days'); let passed = 0; - for (iIndex = 0; iIndex < DateConstants.DATE_ROW_COUNT; iIndex++) { - for (jIndex = 0; jIndex < DateConstants.DATE_COL_COUNT; jIndex++) { + for (iIndex = 0; iIndex < DATE_ROW_COLUMN_COUNT.DATE_ROW_COUNT; iIndex++) { + for (jIndex = 0; jIndex < DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT; jIndex++) { current = lastMonth1; if (passed) { current = current.clone(); @@ -97,7 +99,7 @@ export default class DateTBody extends React.Component { const tableHtml = []; passed = 0; - for (iIndex = 0; iIndex < DateConstants.DATE_ROW_COUNT; iIndex++) { + for (iIndex = 0; iIndex < DATE_ROW_COLUMN_COUNT.DATE_ROW_COUNT; iIndex++) { let isCurrentWeek; let weekNumberCell; let isActiveWeek = false; @@ -113,11 +115,11 @@ export default class DateTBody extends React.Component { ); } - for (jIndex = 0; jIndex < DateConstants.DATE_COL_COUNT; jIndex++) { + for (jIndex = 0; jIndex < DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT; jIndex++) { let next = null; let last = null; current = dateTable[passed]; - if (jIndex < DateConstants.DATE_COL_COUNT - 1) { + if (jIndex < DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT - 1) { next = dateTable[passed + 1]; } if (jIndex > 0) { diff --git a/src/date/DateTHead.jsx b/src/date/DateTHead.jsx index abed34ac6..0fa1f6968 100644 --- a/src/date/DateTHead.jsx +++ b/src/date/DateTHead.jsx @@ -1,24 +1,30 @@ import React from 'react'; +import DateConstants from './DateConstants'; + +const { DAY_NAME_TO_INDEX } = DateConstants; export default class DateTHead extends React.Component { render() { const props = this.props; const value = props.value; - const localeData = value.localeData(); + const localeData = value.localeData(); const prefixCls = props.prefixCls; - // const veryShortWeekdays = []; - // const weekDays = []; - // const firstDayOfWeek = localeData.firstDayOfWeek(); - // We set Sunday(7) as the first day of the week in seafile-calendar. + const veryShortWeekdays = []; + const weekDays = []; + + const allWeekdaysMin = localeData.weekdaysMin(); + const allWeekdaysShort = localeData.weekdaysShort(); + + let firstDayName = typeof props.firstDayOfWeek === 'string' ? props.firstDayOfWeek[0].toUpperCase() + props.firstDayOfWeek.slice(1) : 'Sunday'; + const firstDay = DAY_NAME_TO_INDEX[firstDayName] ? DAY_NAME_TO_INDEX[firstDayName] : 0; + let showWeekNumberEl; - // for (let dateColIndex = 0; dateColIndex < DateConstants.DATE_COL_COUNT; dateColIndex++) { - // const index = (firstDayOfWeek + dateColIndex) % DateConstants.DATE_COL_COUNT; - // now.day(index); - // veryShortWeekdays[dateColIndex] = localeData.weekdaysMin(); - // weekDays[dateColIndex] = localeData.weekdaysShort(); - // } - const veryShortWeekdays = localeData.weekdaysMin(); - const weekDays = localeData.weekdaysShort(); + for (let dateColIndex = 0; dateColIndex < 7; dateColIndex++) { + const index = (firstDay + dateColIndex) % 7; + veryShortWeekdays[dateColIndex] = allWeekdaysMin[index]; + weekDays[dateColIndex] = allWeekdaysShort[index]; + } + if (props.showWeekNumber) { showWeekNumberEl = ( Date: Tue, 1 Apr 2025 15:22:09 +0800 Subject: [PATCH 32/41] update --- src/date/DateTHead.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/date/DateTHead.jsx b/src/date/DateTHead.jsx index 0fa1f6968..5a7e630a6 100644 --- a/src/date/DateTHead.jsx +++ b/src/date/DateTHead.jsx @@ -7,7 +7,7 @@ export default class DateTHead extends React.Component { render() { const props = this.props; const value = props.value; - const localeData = value.localeData(); + const localeData = value.localeData(); const prefixCls = props.prefixCls; const veryShortWeekdays = []; const weekDays = []; From cf40eadde3118a8482ebe3f10f872a5d0ca26667 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=8E=89=E9=91=AB?= Date: Tue, 1 Apr 2025 15:23:29 +0800 Subject: [PATCH 33/41] update --- src/date/DateTHead.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/date/DateTHead.jsx b/src/date/DateTHead.jsx index 5a7e630a6..4742b68bf 100644 --- a/src/date/DateTHead.jsx +++ b/src/date/DateTHead.jsx @@ -1,7 +1,7 @@ import React from 'react'; import DateConstants from './DateConstants'; -const { DAY_NAME_TO_INDEX } = DateConstants; +const { DAY_NAME_TO_INDEX, DATE_ROW_COLUMN_COUNT } = DateConstants; export default class DateTHead extends React.Component { render() { @@ -19,8 +19,8 @@ export default class DateTHead extends React.Component { const firstDay = DAY_NAME_TO_INDEX[firstDayName] ? DAY_NAME_TO_INDEX[firstDayName] : 0; let showWeekNumberEl; - for (let dateColIndex = 0; dateColIndex < 7; dateColIndex++) { - const index = (firstDay + dateColIndex) % 7; + for (let dateColIndex = 0; dateColIndex < DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT; dateColIndex++) { + const index = (firstDay + dateColIndex) % DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT; veryShortWeekdays[dateColIndex] = allWeekdaysMin[index]; weekDays[dateColIndex] = allWeekdaysShort[index]; } From 302684fe785c3581b627b71ca6c3f298edac364b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=8E=89=E9=91=AB?= Date: Wed, 9 Apr 2025 09:47:56 +0800 Subject: [PATCH 34/41] opt code --- src/Calendar.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Calendar.jsx b/src/Calendar.jsx index 17645fca9..862f93de5 100644 --- a/src/Calendar.jsx +++ b/src/Calendar.jsx @@ -72,6 +72,7 @@ class Calendar extends React.Component { inputMode: PropTypes.string, onBlur: PropTypes.func, onClickRightPanelTime: PropTypes.func, + firstDayOfWeek: PropTypes.string, } static defaultProps = { From 02b5412c5ee9fec9b84c1e4c1d659d498ad54455 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=9B=BD=E7=92=87?= Date: Tue, 15 Apr 2025 10:37:58 +0800 Subject: [PATCH 35/41] fix: code problems --- package.json | 2 +- src/Calendar.jsx | 3 ++- src/date/DateConstants.js | 2 +- src/date/DateTBody.jsx | 4 +++- src/date/DateTHead.jsx | 15 +++++++++------ 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index cc95dd161..46959ee9d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@seafile/seafile-calendar", - "version": "0.0.28", + "version": "0.0.29", "description": "React Calendar", "keywords": [ "react", diff --git a/src/Calendar.jsx b/src/Calendar.jsx index 862f93de5..492192604 100644 --- a/src/Calendar.jsx +++ b/src/Calendar.jsx @@ -288,7 +288,8 @@ class Calendar extends React.Component { const { locale, prefixCls, disabledDate, dateInputPlaceholder, timePicker, onClickRightPanelTime, - disabledTime, clearIcon, renderFooter, inputMode, showHourAndMinute, firstDayOfWeek, showWeekNumber + disabledTime, clearIcon, renderFooter, inputMode, showHourAndMinute, + firstDayOfWeek, showWeekNumber, } = props; const { value, selectedValue, mode } = state; const showTimePicker = mode === 'time'; diff --git a/src/date/DateConstants.js b/src/date/DateConstants.js index 439228b70..e64fd817b 100644 --- a/src/date/DateConstants.js +++ b/src/date/DateConstants.js @@ -15,5 +15,5 @@ const DAY_NAME_TO_INDEX = { export default { DATE_ROW_COLUMN_COUNT, - DAY_NAME_TO_INDEX + DAY_NAME_TO_INDEX, }; diff --git a/src/date/DateTBody.jsx b/src/date/DateTBody.jsx index 5ad7e3060..a9dd61672 100644 --- a/src/date/DateTBody.jsx +++ b/src/date/DateTBody.jsx @@ -77,7 +77,9 @@ export default class DateTBody extends React.Component { let month1 = value.clone(); month1 = month1.date(1); const day = month1.day(); - const firstDayName = typeof firstDayOfWeek === 'string' ? firstDayOfWeek[0].toUpperCase() + firstDayOfWeek.slice(1) : 'Sunday'; + const firstDayName = typeof firstDayOfWeek === 'string' + ? firstDayOfWeek[0].toUpperCase() + firstDayOfWeek.slice(1) + : 'Sunday'; const firstDayIndex = DAY_NAME_TO_INDEX[firstDayName] ? DAY_NAME_TO_INDEX[firstDayName] : 0; const lastMonthDiffDay = (day + 7 - firstDayIndex) % 7; // calculate last month diff --git a/src/date/DateTHead.jsx b/src/date/DateTHead.jsx index 4742b68bf..6001b32ce 100644 --- a/src/date/DateTHead.jsx +++ b/src/date/DateTHead.jsx @@ -11,16 +11,19 @@ export default class DateTHead extends React.Component { const prefixCls = props.prefixCls; const veryShortWeekdays = []; const weekDays = []; - + const allWeekdaysMin = localeData.weekdaysMin(); const allWeekdaysShort = localeData.weekdaysShort(); - - let firstDayName = typeof props.firstDayOfWeek === 'string' ? props.firstDayOfWeek[0].toUpperCase() + props.firstDayOfWeek.slice(1) : 'Sunday'; + + const firstDayName = typeof props.firstDayOfWeek === 'string' + ? props.firstDayOfWeek[0].toUpperCase() + props.firstDayOfWeek.slice(1) + : 'Sunday'; const firstDay = DAY_NAME_TO_INDEX[firstDayName] ? DAY_NAME_TO_INDEX[firstDayName] : 0; - + let showWeekNumberEl; - for (let dateColIndex = 0; dateColIndex < DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT; dateColIndex++) { - const index = (firstDay + dateColIndex) % DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT; + const dateColumnCount = DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT; + for (let dateColIndex = 0; dateColIndex < dateColumnCount; dateColIndex++) { + const index = (firstDay + dateColIndex) % dateColumnCount; veryShortWeekdays[dateColIndex] = allWeekdaysMin[index]; weekDays[dateColIndex] = allWeekdaysShort[index]; } From 5ad60a598425d40211aa8b5b0b245dec551b2371 Mon Sep 17 00:00:00 2001 From: GongFlying <150640661+gzcqqqqqqqq1@users.noreply.github.com> Date: Fri, 23 May 2025 11:10:25 +0800 Subject: [PATCH 36/41] remove input rule --- src/date/DateInput.js | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/src/date/DateInput.js b/src/date/DateInput.js index 01af7aa84..3f5f6f6a8 100644 --- a/src/date/DateInput.js +++ b/src/date/DateInput.js @@ -35,13 +35,12 @@ class DateInput extends React.Component { this.state = { str: formatDate(selectedValue, this.props.format), - invalid: false, hasFocus: false, }; } componentDidUpdate() { - if (dateInputInstance && this.state.hasFocus && !this.state.invalid && + if (dateInputInstance && this.state.hasFocus && !(cachedSelectionStart === 0 && cachedSelectionEnd === 0)) { dateInputInstance.setSelectionRange(cachedSelectionStart, cachedSelectionEnd); } @@ -61,20 +60,14 @@ class DateInput extends React.Component { // 没有内容,合法并直接退出 if (!str) { onChange(null); - this.setState({ - invalid: false, - str, - }); + this.setState({ str }); return; } // 不合法直接退出 const parsed = dayjs(str, format, true); if (!parsed.isValid()) { - this.setState({ - invalid: true, - str, - }); + this.setState({ str }); return; } @@ -88,20 +81,14 @@ class DateInput extends React.Component { .second(parsed.second()); if (!value || (disabledDate && disabledDate(value))) { - this.setState({ - invalid: true, - str, - }); + this.setState({ str }); return; } if (selectedValue !== value || ( selectedValue && value && !selectedValue.isSame(value) )) { - this.setState({ - invalid: false, - str, - }); + this.setState({ str }); onChange(value); } } @@ -139,10 +126,7 @@ class DateInput extends React.Component { // when popup show, click body will call this, bug! const selectedValue = nextProps.selectedValue; if (!state.hasFocus) { - newState = { - str: formatDate(selectedValue, nextProps.format), - invalid: false, - }; + newState = { str: formatDate(selectedValue, nextProps.format) }; } return newState; @@ -168,15 +152,14 @@ class DateInput extends React.Component { render() { const props = this.props; - const { invalid, str } = this.state; + const { str } = this.state; const { locale, prefixCls, placeholder, clearIcon, inputMode } = props; - const invalidClass = invalid ? `${prefixCls}-input-invalid` : ''; return (
Date: Tue, 27 May 2025 18:11:23 +0800 Subject: [PATCH 37/41] Time algorithm adjustment --- examples/antd-calendar.js | 8 +- examples/antd-month-calendar.js | 4 +- examples/antd-range-calendar.js | 12 +- examples/custom-clear-icon.js | 4 +- examples/full-calendar.js | 4 +- examples/getCalendarContainer.js | 4 +- examples/start-end-range.js | 4 +- examples/start-end.js | 4 +- examples/week.js | 4 +- index.d.ts | 22 +-- package.json | 3 +- rc-calendar-tests.tsx | 10 +- src/Calendar.jsx | 18 +-- src/FullCalendar.jsx | 4 +- src/MonthCalendar.jsx | 4 +- src/RangeCalendar.js | 8 +- src/calendar/CalendarRightPanel.jsx | 5 +- src/date/DateInput.js | 221 ++++++++++++++++++++++++++-- src/mixin/CalendarMixin.js | 4 +- src/util/dayjs.js | 32 ++-- src/util/index.js | 135 ++++++++++++++++- tests/Calendar.spec.jsx | 40 ++--- tests/FullCalendar.spec.js | 4 +- tests/MonthCalendar.spec.js | 10 +- tests/Picker.spec.jsx | 26 ++-- tests/RangeCalendar.spec.jsx | 68 ++++----- 26 files changed, 489 insertions(+), 173 deletions(-) diff --git a/examples/antd-calendar.js b/examples/antd-calendar.js index 6170fefdb..1121bf9b4 100644 --- a/examples/antd-calendar.js +++ b/examples/antd-calendar.js @@ -10,12 +10,12 @@ import zhCN from '@seafile/seafile-calendar/src/locale/zh_CN'; import enUS from '@seafile/seafile-calendar/src/locale/en_US'; import 'rc-time-picker/assets/index.css'; import TimePickerPanel from 'rc-time-picker/lib/Panel'; -import dayjs from '../src/util/dayjs'; +import moment from 'moment'; const format = 'YYYY-MM-DD HH:mm:ss'; const cn = location.search.indexOf('cn') !== -1; -let now = dayjs(); +let now = moment(); if (cn) { now = now.locale('zh-cn'); } else { @@ -30,7 +30,7 @@ function getFormat(time) { const defaultCalendarValue = now.clone(); defaultCalendarValue.add(-1, 'month'); -const timePickerElement = ; +const timePickerElement = ; function disabledTime(date) { console.log('disabledTime', date); @@ -54,7 +54,7 @@ function disabledDate(current) { // allow empty select return false; } - let date = dayjs().locale('zh-cn'); + let date = moment().locale('zh-cn'); date = date.hour(0); date = date.minute(0); date = date.second(0); diff --git a/examples/antd-month-calendar.js b/examples/antd-month-calendar.js index c67a79b6a..eafec9d32 100644 --- a/examples/antd-month-calendar.js +++ b/examples/antd-month-calendar.js @@ -10,12 +10,12 @@ import DatePicker from '@seafile/seafile-calendar/src/Picker'; import zhCN from '@seafile/seafile-calendar/src/locale/zh_CN'; import enUS from '@seafile/seafile-calendar/src/locale/en_US'; -import dayjs from '../src/util/dayjs'; +import moment from 'moment'; const format = 'YYYY-MM'; const cn = location.search.indexOf('cn') !== -1; -const now = dayjs(); +const now = moment(); if (cn) { now.locale('zh-cn').utcOffset(8); } else { diff --git a/examples/antd-range-calendar.js b/examples/antd-range-calendar.js index 0fb941936..82bfd236d 100644 --- a/examples/antd-range-calendar.js +++ b/examples/antd-range-calendar.js @@ -10,17 +10,17 @@ import TimePickerPanel from 'rc-time-picker/lib/Panel'; import '@seafile/seafile-calendar/assets/index.less'; import 'rc-time-picker/assets/index.css'; -import dayjs from '../src/util/dayjs'; +import moment from 'moment'; const cn = location.search.indexOf('cn') !== -1; if (cn) { - dayjs.locale('zh-cn'); + moment.locale('zh-cn'); } else { - dayjs.locale('en-gb'); + moment.locale('en-gb'); } -const now = dayjs(); +const now = moment(); if (cn) { now.utcOffset(8); } else { @@ -32,7 +32,7 @@ defaultCalendarValue.add(-1, 'month'); const timePickerElement = ( ); @@ -45,7 +45,7 @@ function newArray(start, end) { } function disabledDate(current) { - let date = dayjs(); + let date = moment(); date = date.hour(0); date = date.minute(0); date = date.second(0); diff --git a/examples/custom-clear-icon.js b/examples/custom-clear-icon.js index 74f8fa565..f5f6fe71d 100644 --- a/examples/custom-clear-icon.js +++ b/examples/custom-clear-icon.js @@ -7,8 +7,8 @@ import Calendar from '@seafile/seafile-calendar'; import RangeCalendar from '@seafile/seafile-calendar/src/RangeCalendar'; import 'rc-time-picker/assets/index.css'; -import 'dayjs/locale/zh-cn'; -import 'dayjs/locale/en-gb'; +import 'moment/locale/zh-cn'; +import 'moment/locale/en-gb'; const clearPath = 'M909.1 209.3l-56.4 44.1C775.8 155.1 656.2 92 521.9 92 ' + '290 92 102.3 279.5 102 511.5 101.7 743.7 289.8 932 521.9 932c181.3 0' + diff --git a/examples/full-calendar.js b/examples/full-calendar.js index 3761a353f..e3323256f 100644 --- a/examples/full-calendar.js +++ b/examples/full-calendar.js @@ -11,12 +11,12 @@ import Select from 'rc-select'; import zhCN from '@seafile/seafile-calendar/src/locale/zh_CN'; import enUS from '@seafile/seafile-calendar/src/locale/en_US'; -import dayjs from '../src/util/dayjs'; +import moment from 'moment'; const format = 'YYYY-MM-DD'; const cn = location.search.indexOf('cn') !== -1; -const now = dayjs(); +const now = moment(); if (cn) { now.locale('zh-cn').utcOffset(8); } else { diff --git a/examples/getCalendarContainer.js b/examples/getCalendarContainer.js index c8148961d..3d956cf28 100644 --- a/examples/getCalendarContainer.js +++ b/examples/getCalendarContainer.js @@ -9,12 +9,12 @@ import 'rc-dialog/assets/index.css'; import zhCN from '@seafile/seafile-calendar/src/locale/zh_CN'; import enUS from '@seafile/seafile-calendar/src/locale/en_US'; -import dayjs from '../src/util/dayjs'; +import moment from 'moment'; const format = 'YYYY-MM-DD'; const cn = location.search.indexOf('cn') !== -1; -const now = dayjs(); +const now = moment(); if (cn) { now.locale('zh-cn').utcOffset(8); } else { diff --git a/examples/start-end-range.js b/examples/start-end-range.js index 244c9b50a..ee4cfe41b 100644 --- a/examples/start-end-range.js +++ b/examples/start-end-range.js @@ -9,14 +9,14 @@ import DatePicker from '@seafile/seafile-calendar/src/Picker'; import zhCN from '@seafile/seafile-calendar/src/locale/zh_CN'; import enUS from '@seafile/seafile-calendar/src/locale/en_US'; -import dayjs from '../src/util/dayjs'; +import moment from 'moment'; const format = 'YYYY-MM-DD'; const fullFormat = 'YYYY-MM-DD dddd'; const cn = location.search.indexOf('cn') !== -1; -const now = dayjs(); +const now = moment(); if (cn) { now.locale('zh-cn').utcOffset(8); } else { diff --git a/examples/start-end.js b/examples/start-end.js index a09423e12..aaf0d5132 100644 --- a/examples/start-end.js +++ b/examples/start-end.js @@ -11,12 +11,12 @@ import enUS from '@seafile/seafile-calendar/src/locale/en_US'; import 'rc-time-picker/assets/index.css'; import TimePickerPanel from 'rc-time-picker/lib/Panel'; -import dayjs from '../src/util/dayjs'; +import moment from 'moment'; const format = 'YYYY-MM-DD HH:mm:ss'; const cn = location.search.indexOf('cn') !== -1; -const now = dayjs(); +const now = moment(); if (cn) { now.locale('zh-cn').utcOffset(8); } else { diff --git a/examples/week.js b/examples/week.js index 538a39b2b..c4e3d7900 100644 --- a/examples/week.js +++ b/examples/week.js @@ -9,12 +9,12 @@ import DatePicker from '@seafile/seafile-calendar/src/Picker'; import zhCN from '@seafile/seafile-calendar/src/locale/zh_CN'; import enUS from '@seafile/seafile-calendar/src/locale/en_US'; -import dayjs from '../src/util/dayjs'; +import moment from 'moment'; const format = 'YYYY-wo'; const cn = location.search.indexOf('cn') !== -1; -const now = dayjs(); +const now = moment(); if (cn) { now.locale('zh-cn').utcOffset(8); } else { diff --git a/index.d.ts b/index.d.ts index 13e00bf9f..55f6cfc71 100644 --- a/index.d.ts +++ b/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/react-component/calendar import * as React from 'react'; -import { Dayjs } from 'dayjs'; +import {moment} from 'moment'; export type Mode = 'time' | 'date' | 'month' | 'year' | 'decade'; @@ -12,9 +12,9 @@ export interface Props { prefixCls?: string; className?: string; style?: React.CSSProperties; - defaultValue?: Dayjs; - value?: Dayjs; - selectedValue?: Dayjs; + defaultValue?: moment; + value?: moment; + selectedValue?: moment; mode?: Mode; locale?: object; format?: string | string[]; @@ -22,21 +22,21 @@ export interface Props { showWeekNumber?: boolean; showToday?: boolean; showOk?: boolean; - onSelect?: (date: Dayjs) => void; + onSelect?: ( date: moment ) => void; onOk?: () => void; onKeyDown?: () => void; onClickRightPanelTime?: () => void; timePicker?: React.ReactNode; dateInputPlaceholder?: string; onClear?: () => void; - onChange?: (date: Dayjs | null) => void; - onPanelChange?: (date: Dayjs | null, mode: Mode) => void; - disabledDate?: (current: Dayjs | undefined) => boolean; - disabledTime?: (current: Dayjs | undefined) => object; - dateRender?: (current: Dayjs, value: Dayjs) => React.ReactNode; + onChange?: ( date: moment | null ) => void; + onPanelChange?: ( date: moment | null, mode: Mode ) => void; + disabledDate?: ( current: moment | undefined ) => boolean; + disabledTime?: ( current: moment | undefined ) => object; + dateRender?: ( current: moment, value: moment ) => React.ReactNode; renderFooter?: () => React.ReactNode; renderSidebar?: () => React.ReactNode; inputMode?: string; } -export default class ReactCalendar extends React.Component {} +export default class ReactCalendar extends React.Component { } diff --git a/package.json b/package.json index 46959ee9d..ff9beaebb 100644 --- a/package.json +++ b/package.json @@ -91,7 +91,8 @@ "dependencies": { "babel-runtime": "6.x", "classnames": "2.x", - "dayjs": "1.10.7", + "moment": "1.10.7", + "moment": "^2.30.1", "prop-types": "^15.5.8", "rc-trigger": "^2.2.0", "rc-util": "^4.1.1", diff --git a/rc-calendar-tests.tsx b/rc-calendar-tests.tsx index afa4d690f..a9d40fc25 100644 --- a/rc-calendar-tests.tsx +++ b/rc-calendar-tests.tsx @@ -1,20 +1,20 @@ import * as React from 'react'; -import * as dayjs from 'dayjs'; +import moment, {Moment} from 'moment'; import Calendar from './'; -const action = (date: dayjs.Dayjs) => { - date.subtract(1); +const action = ( date: Moment ) => { + date.subtract( 1, 'day' ); }; export default () => ( false} + disabledDate={( now: Moment ) => false} onSelect={action} inputMode="numeric" /> diff --git a/src/Calendar.jsx b/src/Calendar.jsx index 492192604..7686ab620 100644 --- a/src/Calendar.jsx +++ b/src/Calendar.jsx @@ -3,7 +3,7 @@ import ReactDOM from 'react-dom'; import PropTypes from 'prop-types'; import KeyCode from 'rc-util/lib/KeyCode'; import { polyfill } from 'react-lifecycles-compat'; -import dayjs from 'dayjs'; +import moment from 'moment'; import DateTable from './date/DateTable'; import CalendarHeader from './calendar/CalendarHeader'; import CalendarFooter from './calendar/CalendarFooter'; @@ -18,18 +18,15 @@ import { commonMixinWrapper, propType, defaultProp } from './mixin/CommonMixin'; import DateInput from './date/DateInput'; import { getTimeConfig, getTodayTime, syncTime } from './util'; import { goStartMonth, goEndMonth, goTime } from './util/toTime'; -import localeData from 'dayjs/plugin/localeData'; -import utc from 'dayjs/plugin/utc'; -import weekOfYear from 'dayjs/plugin/weekOfYear'; -dayjs.extend(utc); -dayjs.extend(localeData); -dayjs.extend(weekOfYear); +moment.localeData(); +moment().utc(); +moment().week(); function noop() { } const getMomentObjectIfValid = date => { - if (dayjs.isDayjs(date) && date.isValid()) { + if (moment.isMoment(date) && date.isValid()) { return date; } return false; @@ -96,7 +93,7 @@ class Calendar extends React.Component { value: getMomentObjectIfValid(props.value) || getMomentObjectIfValid(props.defaultValue) || - dayjs(), + moment(), selectedValue: props.selectedValue || props.defaultSelectedValue, }; } @@ -323,7 +320,7 @@ class Calendar extends React.Component { key="date-input" value={value} locale={locale} - placeholder={dateInputPlaceholder} + placeholder={dateInputPlaceholder || this.getFormat()[0]} showClear disabledTime={disabledTime} disabledDate={disabledDate} @@ -334,6 +331,7 @@ class Calendar extends React.Component { onSelect={this.onDateInputSelect} clearIcon={clearIcon} inputMode={inputMode} + showHourAndMinute={showHourAndMinute} /> ) : null; diff --git a/src/FullCalendar.jsx b/src/FullCalendar.jsx index 4745406e9..90fdb7f66 100644 --- a/src/FullCalendar.jsx +++ b/src/FullCalendar.jsx @@ -11,7 +11,7 @@ import { } from './mixin/CalendarMixin'; import { commonMixinWrapper, propType, defaultProp } from './mixin/CommonMixin'; import CalendarHeader from './full-calendar/CalendarHeader'; -import dayjs from './util/dayjs'; +import moment from 'moment'; class FullCalendar extends React.Component { static propTypes = { @@ -61,7 +61,7 @@ class FullCalendar extends React.Component { this.state = { type, - value: props.value || props.defaultValue || dayjs(), + value: props.value || props.defaultValue || moment(), selectedValue: props.selectedValue || props.defaultSelectedValue, }; } diff --git a/src/MonthCalendar.jsx b/src/MonthCalendar.jsx index f2010ae36..2552b6d51 100644 --- a/src/MonthCalendar.jsx +++ b/src/MonthCalendar.jsx @@ -10,7 +10,7 @@ import { calendarMixinDefaultProps, } from './mixin/CalendarMixin'; import { commonMixinWrapper, propType, defaultProp } from './mixin/CommonMixin'; -import dayjs from './util/dayjs'; +import moment from 'moment'; class MonthCalendar extends React.Component { static propTypes = { @@ -31,7 +31,7 @@ class MonthCalendar extends React.Component { this.state = { mode: 'month', - value: props.value || props.defaultValue || dayjs(), + value: props.value || props.defaultValue || moment(), selectedValue: props.selectedValue || props.defaultSelectedValue, }; } diff --git a/src/RangeCalendar.js b/src/RangeCalendar.js index 6783b590c..615e8ef3b 100644 --- a/src/RangeCalendar.js +++ b/src/RangeCalendar.js @@ -10,7 +10,7 @@ import TimePickerButton from './calendar/TimePickerButton'; import { commonMixinWrapper, propType, defaultProp } from './mixin/CommonMixin'; import { syncTime, getTodayTime, isAllowedDate } from './util'; import { goTime, goStartMonth, goEndMonth, includesTime } from './util/toTime'; -import dayjs from './util/dayjs'; +import moment from 'moment'; function noop() { } @@ -50,7 +50,7 @@ function normalizeAnchor(props, init) { getValueFromSelectedValue(value) : getValueFromSelectedValue(selectedValue); return !isEmptyArray(normalizedValue) ? - normalizedValue : init && [dayjs(), dayjs().add(1, 'months')]; + normalizedValue : init && [moment(), moment().add(1, 'months')]; } function generateOptions(length, extraOptionGen) { @@ -210,7 +210,7 @@ class RangeCalendar extends React.Component { let nextHoverValue; if (!firstSelectedValue) { - currentHoverTime = hoverValue[0] || selectedValue[0] || value[0] || dayjs(); + currentHoverTime = hoverValue[0] || selectedValue[0] || value[0] || moment(); nextHoverTime = func(currentHoverTime); nextHoverValue = [nextHoverTime]; this.fireHoverValueChange(nextHoverValue); @@ -571,7 +571,7 @@ class RangeCalendar extends React.Component { // 尚未选择过时间,直接输入的话 if (!this.state.selectedValue[0] || !this.state.selectedValue[1]) { - const startValue = selectedValue[0] || dayjs(); + const startValue = selectedValue[0] || moment(); const endValue = selectedValue[1] || startValue.clone().add(1, 'months'); this.setState({ selectedValue, diff --git a/src/calendar/CalendarRightPanel.jsx b/src/calendar/CalendarRightPanel.jsx index 861378753..ce3e0b24e 100644 --- a/src/calendar/CalendarRightPanel.jsx +++ b/src/calendar/CalendarRightPanel.jsx @@ -1,6 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; -import dayjs from 'dayjs'; +import moment from 'moment'; export default class CalendarRightPanel extends React.Component { @@ -11,6 +11,7 @@ export default class CalendarRightPanel extends React.Component { onClickRightPanelTime: PropTypes.func, locale: PropTypes.object, defaultMinutesTime: PropTypes.string, + cananderIput: PropTypes.string, } constructor(props) { @@ -70,7 +71,7 @@ export default class CalendarRightPanel extends React.Component {
    {this.times.map((time) => { - let current = dayjs(`${selectedDate} ${time}`); + let current = moment(`${selectedDate} ${time}`); current = isZhcn ? current.locale('zh-cn') : current.locale('en-gb'); return (
  • { const str = event.target.value; - const { disabledDate, format, onChange, selectedValue } = this.props; + const { disabledDate, showHourAndMinute, onChange, selectedValue } = this.props; + const cananderStr = this.normalizeDateInput(str, showHourAndMinute); + const parts = formatDateLocal(cananderStr, this.state.localeFormat); + this.setState({ cananderIput: cananderStr }); // 没有内容,合法并直接退出 if (!str) { onChange(null); @@ -65,21 +86,35 @@ class DateInput extends React.Component { } // 不合法直接退出 - const parsed = dayjs(str, format, true); - if (!parsed.isValid()) { - this.setState({ str }); - return; + let format = getDateFormatByStr(cananderStr, this.state.localeFormat); + if (/\d{1,2}:\d{2}$/.test(cananderStr) && showHourAndMinute) { + format += ' HH:mm'; } + const parsed = moment(cananderStr, format); let value = this.props.value.clone(); value = value .year(parsed.year()) .month(parsed.month()) .date(parsed.date()) - .hour(parsed.hour()) - .minute(parsed.minute()) - .second(parsed.second()); - + .hour(parsed.hour() || moment().hour()) + .minute(parsed.minute() || moment().minute()) + .second(parsed.second() || moment().second()); + if (this.state.localeFormat === DATE_FORMATS.ISO) { + if (parts[0] && parts[0].length === 4 && (parts[0].slice(0, 3) === '000' || + parts[0].slice(0, 2) === '00')) { + value.year(parts[0]); + } + } + if (this.state.localeFormat === DATE_FORMATS.European || + this.state.localeFormat === DATE_FORMATS.US || + this.state.localeFormat === DATE_FORMATS.Germany_Russia_etc + ) { + if (parts[2] && parts[2].length === 4 && (parts[2].slice(0, 3) === '000' || + parts[2].slice(0, 2) === '00')) { + value.year(parts[2]); + } + } if (!value || (disabledDate && disabledDate(value))) { this.setState({ str }); return; @@ -126,9 +161,26 @@ class DateInput extends React.Component { // when popup show, click body will call this, bug! const selectedValue = nextProps.selectedValue; if (!state.hasFocus) { - newState = { str: formatDate(selectedValue, nextProps.format) }; + const timeStr = formatDate(selectedValue, nextProps.format).split(' ')[0]; + const parts = timeStr.split(state.delimiter); + const timeParts = formatDate(selectedValue, nextProps.format).split(' ')[1]; + if (state.localeFormat === DATE_FORMATS.ISO) { + if (parts[0].length > 0) { + newState = { str: `${parts[0].padStart(4, 0)}-${parts[1]}-${parts[2]} ${timeParts}` }; + } + } else if (state.localeFormat === DATE_FORMATS.US) { + if (parts.length === 3) { + newState = { str: `${Number(parts[0])}/${Number(parts[1])} + /${parts[2].padStart(4, 0)} ${timeParts}` }; + } + } else if (state.localeFormat === DATE_FORMATS.European || + state.localeFormat === DATE_FORMATS.Germany_Russia_etc) { + if (parts.length === 3) { + newState = { str: `${Number(parts[0])}${state.delimiter}${Number(parts[1])} + ${state.delimiter}${parts[2].padStart(4, 0)} ${timeParts}` }; + } + } } - return newState; } @@ -140,6 +192,145 @@ class DateInput extends React.Component { return ReactDOM.findDOMNode(this); } + normalizeDateInput(str, showHourAndMinute) { + let day; + let month; + let year; + const parts = formatDateLocal(str, this.state.localeFormat, DATE_FORMATS); + const delimiter = this.state.delimiter; + const hasSpecial = hasSpecialChar(str); + if (this.state.localeFormat === DATE_FORMATS.ISO) { + const numStr = str.replace(/[^0-9]/g, ''); + if (numStr.length === 7) { + year = numStr.slice(0, 4); + month = numStr.slice(4, 6).padStart(2, '0'); + day = numStr.slice(6, 7).padStart(2, '0'); + if (!isValidDay(day)) { + return `${year}-${stringCurrentMonth}- + ${stringCurrentDate} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; + } + return `${year}-${month}-${day}`; + } + if (hasSpecial) { + year = fullValidYear(parts[0]); + month = Number(parts[1]); + day = Number(parts[2]); + if (month >= 1 && month <= 12) { + if (isValidDay(day)) { + return `${year}-${String(month).padStart(2, '0')}- + ${String(day).padStart(2, '0')} ${showHourAndMinute && + `${parts[3]}:${parts[4]}`}`; + } + return `${year}-${String(month).padStart(2, '0')}- + 01 ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; + } + if ((month >= 13 || month < 1) && isNaN(day)) { + return `${year}-${stringCurrentMonth}- + ${stringCurrentDate} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; + } + if (!month && !day) { + return `${year}-01-01 ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; + } + } + if (str.length >= 1 && str.length <= 8) { + year = fullValidYear(str.slice(0, 4)); + month = str.slice(4, 6); + day = Number(str.slice(6, 8)); + if (str.length === 5 && Number(month) < 1) { + return `${year}-${stringCurrentMonth}- + ${stringCurrentDate} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; + } + if ((str.length === 6 && Number(month) < 1)) { + return `${year}-${stringCurrentMonth}- + ${stringCurrentDate} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; + } + if ((str.length === 7)) { + if (!isValidDay(day)) { + return `${year}-${String(isValidMonth(month)).padStart(2, '0')}- + ${stringCurrentDate} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; + } + return `${year}-${String(isValidMonth(month)).padStart(2, '0')}- + ${String(day).padStart(2, '0')} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; + } + if (str.length === 8) { + if (!isValidDay(day)) { + return `${isCurrentYear(year, month, day)}- + ${String(isValidMonth(month)).padStart(2, '0')} + -${stringCurrentDate} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; + } + return `${isCurrentYear(year, month, day)}- + ${String(isValidMonth(month)).padStart(2, '0')} + -${String(day).padStart(2, '0')} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; + } + if (Number(month) >= 1 && Number(month) <= 12 && isValidDay(day)) { + return `${year}-${month.padStart(2, '0')}- + ${String(day).padStart(2, '0')} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; + } + return `${year}- + ${month ? month.padStart(2, '0') : '01'}- + ${day ? + String(day).padStart(2, '0') : + '01'} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; + } + return `${currentYear}/${stringCurrentMonth}/${stringCurrentDate}`; + } + if (this.state.localeFormat === DATE_FORMATS.US) { + if (hasSpecial) { + month = Number(parts[0]); + day = Number(parts[1]); + year = fullValidYear(parts[2]); + if (month >= 1 && month <= 12 && isValidDay(day)) { + return `${month}/${day}/${year} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; + } + } + if (str.length >= 1 && str.length <= 8) { + month = Number(str.slice(0, 2)); + day = Number(str.slice(2, 4)); + year = fullValidYear(str.slice(4, str.length)); + if (month >= 1 && month <= 12) { + if (isValidDay(day)) { + return `${month}/${day}/${year} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; + } + if (!day) { + return `${month}/1/ + ${year} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; + } + return `${month}/${day}/ + ${year} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; + } + } + return `${currentMonth}/ + ${currentDate}/ + ${currentYear} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; + } + if (this.state.localeFormat === DATE_FORMATS.European || + this.state.localeFormat === DATE_FORMATS.Germany_Russia_etc) { + if (hasSpecial) { + month = parts[1]; + year = fullValidYear(parts[2]); + if (isValidDay(parts[0]) && Number(month) >= 1 && Number(month) <= 12) { + return `${Number(parts[0])}${delimiter}${Number(month)} + ${delimiter}${year} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; + } + return `${currentDate}${delimiter}${currentMonth} + ${delimiter}${currentYear} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; + } + if (str.length >= 1 && str.length <= 8) { + day = Number(str.slice(0, 2)); + const monthStr = str.slice(2, 4); + month = isValidMonth(monthStr); + const yearStr = str.slice(4, str.length); + year = fullValidYear(yearStr); + if (isValidDay(day)) { + return `${Number(day)}${delimiter}${Number(month)} + ${delimiter}${year} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; + } + } + return `${currentDate}${delimiter}${currentMonth} + ${delimiter}${currentYear} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; + } + } + focus = () => { if (dateInputInstance) { dateInputInstance.focus(); diff --git a/src/mixin/CalendarMixin.js b/src/mixin/CalendarMixin.js index 0165fe14e..49a2fe3eb 100644 --- a/src/mixin/CalendarMixin.js +++ b/src/mixin/CalendarMixin.js @@ -1,7 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; -import dayjs from 'dayjs'; +import moment from 'moment'; import { isAllowedDate, getTodayTime } from '../util/index'; function noop() { @@ -12,7 +12,7 @@ export function getNowByCurrentStateValue(value) { if (value) { ret = getTodayTime(value); } else { - ret = dayjs(); + ret = moment(); } return ret; } diff --git a/src/util/dayjs.js b/src/util/dayjs.js index 46eebcbe6..2b4c0607c 100644 --- a/src/util/dayjs.js +++ b/src/util/dayjs.js @@ -1,17 +1,17 @@ -import dayjs from 'dayjs'; -import localeData from 'dayjs/plugin/localeData'; -import weekOfYear from 'dayjs/plugin/weekOfYear'; -import utc from 'dayjs/plugin/utc'; -import advancedFormat from 'dayjs/plugin/advancedFormat'; -import customParseFormat from 'dayjs/plugin/customParseFormat'; -import badMutable from 'dayjs/plugin/badMutable'; -import 'dayjs/locale/zh-cn'; -import 'dayjs/locale/en-gb'; +import moment from 'moment'; +import localeData from 'moment/plugin/localeData'; +import weekOfYear from 'moment/plugin/weekOfYear'; +import utc from 'moment/plugin/utc'; +import advancedFormat from 'moment/plugin/advancedFormat'; +import customParseFormat from 'moment/plugin/customParseFormat'; +import badMutable from 'moment/plugin/badMutable'; +import 'moment/locale/zh-cn'; +import 'moment/locale/en-gb'; -dayjs.extend(localeData); -dayjs.extend(weekOfYear); -dayjs.extend(utc); -dayjs.extend(advancedFormat); -dayjs.extend(customParseFormat); -dayjs.extend(badMutable); -export default dayjs; +moment.extend(localeData); +moment.extend(weekOfYear); +moment.extend(utc); +moment.extend(advancedFormat); +moment.extend(customParseFormat); +moment.extend(badMutable); +export default moment; diff --git a/src/util/index.js b/src/util/index.js index 73782ab6d..3bc181d56 100644 --- a/src/util/index.js +++ b/src/util/index.js @@ -1,7 +1,18 @@ -import dayjs from 'dayjs'; -import utc from 'dayjs/plugin/utc'; +import moment from 'moment'; -dayjs.extend(utc); +export const currentDate = moment().date(); +export const currentMonth = moment().month() + 1; +export const currentYear = moment().year(); +export const nowTime = moment().format('HH:mm'); +export const stringCurrentDate = String(currentDate).padStart(2, '0'); +export const stringCurrentMonth = String(currentMonth).padStart(2, '0'); + +export const DATE_FORMATS = { + ISO: 'YYYY-MM-DD', + US: 'M/D/YYYY', + European: 'DD/MM/YYYY', + Germany_Russia_etc: 'DD.MM.YYYY', +}; const defaultDisabledTime = { disabledHours() { @@ -16,7 +27,7 @@ const defaultDisabledTime = { }; export function getTodayTime(value) { - let today = dayjs(); + let today = moment(); today = today.locale(value.locale()).utcOffset(value.utcOffset()); return today; } @@ -37,7 +48,7 @@ export function getMonthName(month) { } export function syncTime(from, to) { - if (!dayjs.isDayjs(from) || !dayjs.isDayjs(to)) return; + if (!moment.isMoment(from) || !moment.isMoment(to)) return; to = to.hour(from.hour()); to = to.minute(from.minute()); to = to.second(from.second()); @@ -105,3 +116,117 @@ export function formatDate(value, format) { return value.format(format); } + +export function formatDateLocal(formatStr, format) { + const str = formatStr || ''; + let cleanStr; + switch (format) { + case DATE_FORMATS.ISO: + cleanStr = str.replace(/[^0-9]+/g, '-'); + return cleanStr.split('-').filter(Boolean).map(String); + case DATE_FORMATS.US: + case DATE_FORMATS.European: + cleanStr = str.replace(/[^0-9]+/g, '/'); + return cleanStr.split('/').filter(Boolean).map(String); + case DATE_FORMATS.Germany_Russia_etc: + cleanStr = str.replace(/[^0-9]+/g, '.'); + return cleanStr.split('.').filter(Boolean).map(String); + default: + return []; + } +} + +export function hasSpecialChar(str) { + const matches = str.match(/[^0-9]/g); + return matches ? matches.length : 0; +} + +export function isValidMonth(monthStr) { + if (typeof monthStr === 'undefined' || monthStr === null) return currentMonth; + if (!/^\d+$/.test(Number(monthStr))) return currentMonth; + const month = Number(monthStr); + if (month >= 1 && month <= 12) { + return monthStr; + } + return currentMonth; +} + +export function isValidDay(dayStr) { + if (!/^\d+$/.test(dayStr)) return false; + const day = Number(dayStr); + if ([1, 3, 5, 7, 8, 10, 12].includes(currentMonth)) { + return day >= 1 && day <= 31; + } + if ([4, 6, 9, 11].includes(currentMonth)) { + return day >= 1 && day <= 30; + } + if (currentMonth === 2) { + const isLeapYear = (year) => { + return (year % 4 === 0 && year % 100 !== 0) || (year % 400 === 0); + }; + const year = currentYear; + if (isLeapYear(year)) { + return day >= 1 && day <= 29; + } + return day >= 1 && day <= 28; + } +} + +export function fullValidYear(yearStr) { + const year = yearStr; + if (!year || isNaN(year)) return currentYear; + if (year.length === 2) { + if (Number(year) >= 0 && Number(year) < 69) { + return year ? `20${year}` : currentYear; + } else if (Number(year) >= 69 && Number(year) < 100) { + return year ? `19${year}` : currentYear; + } + } + if (year.length === 4) { + return year; + } + return year ? year.padStart(4, '0') : currentYear; +} + +export function getDateFormatByStr(str, format) { + const cananderStr = str || ''; + const parts = cananderStr.split('/'); + if (parts.length !== 3) return format; + const delimiter = format === DATE_FORMATS.European ? '/' : '.'; + if (format === DATE_FORMATS.ISO) { + return DATE_FORMATS.ISO; + } + if (format === DATE_FORMATS.US) { + return DATE_FORMATS.US; + } + if ((format === DATE_FORMATS.European) || (format === DATE_FORMATS.Germany_Russia_etc)) { + const [day, month] = parts; + const dayLen = day.length; + const monthLen = month.length; + if (dayLen === 2 && monthLen === 2) { + return `DD${delimiter}MM${delimiter}YYYY`; + } else if (dayLen === 2 && monthLen === 1) { + return `DD${delimiter}M${delimiter}YYYY`; + } else if (dayLen === 1 && monthLen === 2) { + return `D${delimiter}MM${delimiter}YYYY`; + } else if (dayLen === 1 && monthLen === 1) { + return `D${delimiter}M${delimiter}YYYY`; + } + } + return format; +} + +export function isCurrentYear(year, month, day) { + return ( + Number(month) >= 1 && + Number(month) <= 12 && + Number(day) >= 1 && + Number(day) <= 31 + ) + ? year + : currentYear; +} + +export function isShowTimePicker(cananderStr) { + return `${cananderStr} `; +} diff --git a/tests/Calendar.spec.jsx b/tests/Calendar.spec.jsx index 31ccee411..5fa7d2230 100644 --- a/tests/Calendar.spec.jsx +++ b/tests/Calendar.spec.jsx @@ -1,7 +1,7 @@ /* eslint-disable no-undef */ import React from 'react'; import keyCode from 'rc-util/lib/KeyCode'; -import dayjs from '../src/util/dayjs'; +import moment from 'moment'; import { mount, render } from 'enzyme'; import TimePickerPanel from 'rc-time-picker/lib/Panel'; import Calendar from '../src/Calendar'; @@ -14,12 +14,12 @@ describe('Calendar', () => { describe('render', () => { it('render correctly', () => { const zhWrapper = render( - + ); expect(zhWrapper).toMatchSnapshot(); const enWrapper = render( - + ); expect(enWrapper).toMatchSnapshot(); @@ -27,15 +27,15 @@ describe('Calendar', () => { const enWrapperWithMonthFormatWrapper = render( ); expect(enWrapperWithMonthFormatWrapper).toMatchSnapshot(); }); - it('render correctly with invalid dayjs object', () => { + it('render correctly with invalid moment object', () => { const enWrapper = render( - + ); expect(enWrapper).toMatchSnapshot(); }); @@ -48,7 +48,7 @@ describe('Calendar', () => { describe('timePicker', () => { it('set defaultOpenValue if timePicker.props.defaultValue is set', () => { - const timePicker = ; + const timePicker = ; const wrapper = mount(); wrapper.find('.rc-calendar-time-picker-btn').simulate('click'); const selectedValues = wrapper.find('.rc-time-picker-panel-select-option-selected'); @@ -58,9 +58,9 @@ describe('Calendar', () => { }); it('follow Calendar[selectedValue|defaultSelectedValue] when it is set', () => { - const timePicker = ; + const timePicker = ; const wrapper = mount( - + ); wrapper.find('.rc-calendar-time-picker-btn').simulate('click'); const selectedValues = wrapper.find('.rc-time-picker-panel-select-option-selected'); @@ -70,7 +70,7 @@ describe('Calendar', () => { }); it('use timePicker\'s time', () => { - const timePicker = ; + const timePicker = ; const wrapper = mount(); wrapper.find('.rc-calendar-today').simulate('click'); @@ -93,7 +93,7 @@ describe('Calendar', () => { ).toBe('3/8/2017 06:00:00'); }); it('timePicker date have no changes when hover', () => { - const timePicker = ; + const timePicker = ; const wrapper = mount(); wrapper.find('.rc-calendar-time-picker-btn').simulate('click'); const dateBtns = wrapper.find('.rc-calendar-my-select a'); @@ -122,7 +122,7 @@ describe('Calendar', () => { }); it('support controlled mode', () => { - const timePicker = ; + const timePicker = ; let value = null; class ControlledCalendar extends React.Component { state = { mode: 'date' }; @@ -155,14 +155,14 @@ describe('Calendar', () => { expect(wrapper.find('.rc-calendar-year-panel').length).toBe(1); wrapper.find('.rc-calendar-year-panel-decade-select').simulate('click'); expect(wrapper.find('.rc-calendar-decade-panel').length).toBe(1); - expect(value.isSame(dayjs(), 'day')); + expect(value.isSame(moment(), 'day')); wrapper.find('.rc-calendar-decade-panel-selected-cell').simulate('click'); expect(wrapper.find('.rc-calendar-decade-panel').length).toBe(0); wrapper.find('.rc-calendar-year-panel-selected-cell').simulate('click'); expect(wrapper.find('.rc-calendar-year-panel').length).toBe(0); wrapper.find('.rc-calendar-month-panel-selected-cell').simulate('click'); expect(wrapper.find('.rc-calendar-month-panel').length).toBe(0); - expect(value.isSame(dayjs('2010-03-29'), 'day')); + expect(value.isSame(moment('2010-03-29'), 'day')); wrapper.find('.rc-calendar-year-select').simulate('click'); expect(wrapper.find('.rc-calendar-year-panel').length).toBe(1); @@ -351,7 +351,7 @@ describe('Calendar', () => { if (!current) { return false; } - let date = dayjs(); + let date = moment(); date = date.hour(0); date = date.minute(0); date = date.second(0); @@ -587,7 +587,7 @@ describe('Calendar', () => { }); it('handle clear', () => { - const now = dayjs(); + const now = moment(); const calendar = mount( ); @@ -598,7 +598,7 @@ describe('Calendar', () => { describe('onOk', () => { it('triggers onOk', () => { - const selected = dayjs().add(1, 'day'); + const selected = moment().add(1, 'day'); const handleOk = jest.fn(); const calendar = mount( @@ -618,7 +618,7 @@ describe('Calendar', () => { }); it('does not triggers onOk if selected date is disabled', () => { - const selected = dayjs().add(1, 'day'); + const selected = moment().add(1, 'day'); const handleOk = jest.fn(); const calendar = mount( { }); it('today button', () => { - const selected = dayjs().add(1, 'day').utcOffset(480); + const selected = moment().add(1, 'day').utcOffset(480); const calendar = mount( ); calendar.find('.rc-calendar-today-btn').simulate('click'); - expect(dayjs().isSame(calendar.state().selectedValue)).toBe(true); + expect(moment().isSame(calendar.state().selectedValue)).toBe(true); }); }); diff --git a/tests/FullCalendar.spec.js b/tests/FullCalendar.spec.js index 8d722b995..75969ba24 100644 --- a/tests/FullCalendar.spec.js +++ b/tests/FullCalendar.spec.js @@ -2,7 +2,7 @@ import React from 'react'; import Select from 'rc-select'; import { render, mount } from 'enzyme'; -import dayjs from '../src/util/dayjs'; +import moment from 'moment'; import FullCalendar from '../src/FullCalendar'; describe('FullCalendar', () => { @@ -82,7 +82,7 @@ describe('FullCalendar', () => { }); it('select month', () => { - const selected = dayjs().add(1, 'month'); + const selected = moment().add(1, 'month'); const wrapper = mount( { it('year or decade panel work correctly', () => { @@ -19,7 +19,7 @@ describe('MonthCalendar', () => { describe('keyboard', () => { let wrapper; beforeEach(() => { - const selected = dayjs().add(2, 'month'); + const selected = moment().add(2, 'month'); wrapper = mount(); }); @@ -38,7 +38,7 @@ describe('MonthCalendar', () => { if (!current) { return false; } - const date = dayjs(); + const date = moment(); return current.month() < date.month(); } @@ -114,10 +114,10 @@ describe('MonthCalendar', () => { }); it('controlled value should work', () => { - const wrapper = mount(); + const wrapper = mount(); expect(wrapper.state().value.format('YYYY-MM-DD')).toBe('2000-01-01'); - wrapper.setProps({ value: dayjs('2049-09-03 00:00:00') }); + wrapper.setProps({ value: moment('2049-09-03 00:00:00') }); expect(wrapper.state().value.format('YYYY-MM-DD')).toBe('2049-09-03'); }); }); diff --git a/tests/Picker.spec.jsx b/tests/Picker.spec.jsx index 1a7bb0397..d67d395e2 100644 --- a/tests/Picker.spec.jsx +++ b/tests/Picker.spec.jsx @@ -5,10 +5,10 @@ import Calendar from '../index'; import DatePicker from '../src/Picker'; import RangeCalendar from '../src/RangeCalendar'; import CalendarLocale from '../src/locale/en_US'; -import dayjs from '../src/util/dayjs'; +import moment from 'moment'; const format = ('YYYY-MM-DD'); -const VALUE = dayjs([2015, 5, 1]); +const VALUE = moment([2015, 5, 1]); describe('DatePicker', () => { function noop() { @@ -134,7 +134,7 @@ describe('DatePicker', () => { }); it('controlled value', () => { - const value = dayjs().add(1, 'day'); + const value = moment().add(1, 'day'); const picker = renderPicker({ value }); expect(picker.state().value).toBe(value); const nextValue = value.clone().add(1, 'day'); @@ -181,14 +181,14 @@ describe('DatePicker', () => { }); it('close on ok', () => { - const picker = renderPicker({ value: dayjs() }); + const picker = renderPicker({ value: moment() }); picker.find('.rc-calendar-picker-input').simulate('click'); picker.find('.rc-calendar-ok-btn').simulate('click'); expect(picker.state().open).toBe(false); }); it('close on clear', () => { - const picker = renderPicker({ value: dayjs() }); + const picker = renderPicker({ value: moment() }); picker.find('.rc-calendar-picker-input').simulate('click'); picker.find('.rc-calendar-clear-btn').simulate('click'); expect(picker.state().open).toBe(false); @@ -196,7 +196,7 @@ describe('DatePicker', () => { describe('DateInput', () => { it('close on enter', () => { - const picker = renderPicker({ value: dayjs() }); + const picker = renderPicker({ value: moment() }); picker.find('.rc-calendar-picker-input').simulate('click'); picker.find('.rc-calendar-input').simulate('keyDown', { keyCode: keyCode.ENTER, @@ -205,7 +205,7 @@ describe('DatePicker', () => { }); it('not close on enter if disabled date', () => { - const picker = renderPicker({ value: dayjs() }, { disabledDate: () => true }); + const picker = renderPicker({ value: moment() }, { disabledDate: () => true }); picker.find('.rc-calendar-picker-input').simulate('click'); picker.find('.rc-calendar-input').simulate('keyDown', { keyCode: keyCode.ENTER, @@ -229,7 +229,7 @@ describe('DatePicker', () => { }); it('close panel when focus is outside of picker', () => { - const picker = renderPicker({ value: dayjs() }, undefined, { + const picker = renderPicker({ value: moment() }, undefined, { attachTo: container, }); picker.find('.rc-calendar-picker-input').simulate('click'); @@ -242,7 +242,7 @@ describe('DatePicker', () => { it('call onBlur when focus is outside of picker', () => { const handleOnBlur = jest.fn(); - const picker = renderPicker({ value: dayjs() }, { onBlur: handleOnBlur }, { + const picker = renderPicker({ value: moment() }, { onBlur: handleOnBlur }, { attachTo: container, }); @@ -254,7 +254,7 @@ describe('DatePicker', () => { }); it('keep panel opened when clicking on calendar next month', () => { - const picker = renderPicker({ value: dayjs() }, undefined, { + const picker = renderPicker({ value: moment() }, undefined, { attachTo: container, }); @@ -270,7 +270,7 @@ describe('DatePicker', () => { it('does not call onBlur when clicking on calendar next month', () => { const handleOnBlur = jest.fn(); - const picker = renderPicker({ value: dayjs() }, { onBlur: handleOnBlur }, { + const picker = renderPicker({ value: moment() }, { onBlur: handleOnBlur }, { attachTo: container, }); @@ -287,7 +287,7 @@ describe('DatePicker', () => { it('auto focuses the calendar input when opening', () => { jest.useFakeTimers(); - const picker = renderPicker({ value: dayjs() }); + const picker = renderPicker({ value: moment() }); picker.find('.rc-calendar-picker-input').simulate('click'); jest.runAllTimers(); expect(document.activeElement).toBeDefined(); @@ -296,7 +296,7 @@ describe('DatePicker', () => { it('auto focuses the calendar div when date input is not shown', () => { jest.useFakeTimers(); - const picker = renderPicker({ value: dayjs() }, { showDateInput: false }); + const picker = renderPicker({ value: moment() }, { showDateInput: false }); picker.find('.rc-calendar-picker-input').simulate('click'); jest.runAllTimers(); expect(document.activeElement).toBeDefined(); diff --git a/tests/RangeCalendar.spec.jsx b/tests/RangeCalendar.spec.jsx index 05de0b492..cb43506b3 100644 --- a/tests/RangeCalendar.spec.jsx +++ b/tests/RangeCalendar.spec.jsx @@ -4,7 +4,7 @@ import { mount, render } from 'enzyme'; import keyCode from 'rc-util/lib/KeyCode'; import TimePickerPanel from 'rc-time-picker/lib/Panel'; import RangeCalendar from '../src/RangeCalendar'; -import dayjs from '../src/util/dayjs'; +import moment from 'moment'; const format = ('YYYY-MM-DD'); @@ -25,7 +25,7 @@ describe('RangeCalendar', () => { }); it('render hoverValue correctly', () => { - const wrapper = render(); + const wrapper = render(); expect(wrapper).toMatchSnapshot(); }); @@ -147,7 +147,7 @@ describe('RangeCalendar', () => { expect(d[1].format(format)).toBe('2015-07-31'); } - const now = dayjs([2015, 8, 29]); + const now = moment([2015, 8, 29]); const wrapper = mount( { expect(d[1].format(format)).toBe('2015-08-10'); } - const now = dayjs([2015, 8, 29]); + const now = moment([2015, 8, 29]); const wrapper = mount( { describe('timePicker', () => { it('defaultOpenValue should follow RangeCalendar[selectedValue|defaultSelectedValue] when it is set', () => { - const timePicker = ; - const wrapper = mount(); + const timePicker = ; + const wrapper = mount(); wrapper.find('.rc-calendar-time-picker-btn').simulate('click'); const selectedValues = wrapper.find('.rc-time-picker-panel-select-option-selected'); for (let i = 0; i < selectedValues.length; i += 1) { @@ -210,8 +210,8 @@ describe('RangeCalendar', () => { }); it('selected start and end date can be same', () => { - const timePicker = ; - const wrapper = mount(); + const timePicker = ; + const wrapper = mount(); wrapper.find('.rc-calendar-time-picker-btn').simulate('click'); expect(wrapper.find('.rc-calendar-year-select').at(0).text()).toBe('2000'); expect(wrapper.find('.rc-calendar-month-select').at(0).text()).toBe('Sep'); @@ -222,7 +222,7 @@ describe('RangeCalendar', () => { }); it('use timePicker\'s time', () => { - const timePicker = ; + const timePicker = ; const wrapper = mount(); wrapper.find('.rc-calendar-today').at(0).simulate('click').simulate('click'); @@ -294,7 +294,7 @@ describe('RangeCalendar', () => { }, }; } - const timePicker = ; + const timePicker = ; const wrapper = mount(); wrapper.find('.rc-calendar-today').at(0).simulate('click').simulate('click'); @@ -323,7 +323,7 @@ describe('RangeCalendar', () => { it('works fine when select reversely', () => { // see: https://github.com/ant-design/ant-design/issues/6440 - const timePicker = ; + const timePicker = ; const wrapper = mount(); wrapper.find('.rc-calendar-cell').at(20).simulate('click'); wrapper.find('.rc-calendar-cell').at(10).simulate('click'); @@ -369,7 +369,7 @@ describe('RangeCalendar', () => { }, }; } - const timePicker = ; + const timePicker = ; const wrapper = mount(); // update same day wrapper.find('.rc-calendar-today').at(0).simulate('click').simulate('click'); @@ -431,7 +431,7 @@ describe('RangeCalendar', () => { it('should work when start time is null in defaultValue', () => { let wrapper = null; - wrapper = mount(); + wrapper = mount(); wrapper.find('.rc-calendar-range-right .rc-calendar-month-select').simulate('click'); expect(wrapper.find('.rc-calendar-range-left .rc-calendar-next-year-btn').length).toBe(1); expect(wrapper.find('.rc-calendar-range-left .rc-calendar-next-month-btn').length).toBe(1); @@ -443,7 +443,7 @@ describe('RangeCalendar', () => { it('should work when end time is null in defaultValue', () => { let wrapper = null; - wrapper = mount(); + wrapper = mount(); wrapper.find('.rc-calendar-range-right .rc-calendar-month-select').simulate('click'); expect(wrapper.find('.rc-calendar-range-left .rc-calendar-next-year-btn').length).toBe(1); expect(wrapper.find('.rc-calendar-range-left .rc-calendar-next-month-btn').length).toBe(1); @@ -455,7 +455,7 @@ describe('RangeCalendar', () => { it('should work when start time is undefined in defaultValue', () => { let wrapper = null; - wrapper = mount(); + wrapper = mount(); wrapper.find('.rc-calendar-range-right .rc-calendar-month-select').simulate('click'); expect(wrapper.find('.rc-calendar-range-left .rc-calendar-next-year-btn').length).toBe(1); expect(wrapper.find('.rc-calendar-range-left .rc-calendar-next-month-btn').length).toBe(1); @@ -467,7 +467,7 @@ describe('RangeCalendar', () => { it('should work when end time is undefined in defaultValue', () => { let wrapper = null; - wrapper = mount(); + wrapper = mount(); wrapper.find('.rc-calendar-range-right .rc-calendar-month-select').simulate('click'); expect(wrapper.find('.rc-calendar-range-left .rc-calendar-next-year-btn').length).toBe(1); expect(wrapper.find('.rc-calendar-range-left .rc-calendar-next-month-btn').length).toBe(1); @@ -502,8 +502,8 @@ describe('RangeCalendar', () => { wrapper.find('.rc-calendar-year-panel-decade-select').at(0).simulate('click'); wrapper.find('.rc-calendar-year-panel-decade-select').at(0).simulate('click'); expect(wrapper.find('.rc-calendar-decade-panel').length).toBe(2); - expect(value[0].isSame(dayjs(), 'day')).toBe(true); - expect(value[1].isSame(dayjs().add(1, 'month'), 'day')).toBe(true); + expect(value[0].isSame(moment(), 'day')).toBe(true); + expect(value[1].isSame(moment().add(1, 'month'), 'day')).toBe(true); wrapper.find('.rc-calendar-decade-panel-selected-cell').at(0).simulate('click'); wrapper.find('.rc-calendar-decade-panel-selected-cell').at(0).simulate('click'); expect(wrapper.find('.rc-calendar-decade-panel').length).toBe(0); @@ -513,8 +513,8 @@ describe('RangeCalendar', () => { wrapper.find('.rc-calendar-month-panel-selected-cell').at(0).simulate('click'); wrapper.find('.rc-calendar-month-panel-selected-cell').at(0).simulate('click'); expect(wrapper.find('.rc-calendar-month-panel').length).toBe(0); - expect(value[0].isSame(dayjs('2010-03-29'), 'day')).toBe(true); - expect(value[1].isSame(dayjs('2010-04-29'), 'day')).toBe(true); + expect(value[0].isSame(moment('2010-03-29'), 'day')).toBe(true); + expect(value[1].isSame(moment('2010-04-29'), 'day')).toBe(true); wrapper.find('.rc-calendar-year-select').at(0).simulate('click'); wrapper.find('.rc-calendar-year-select').at(1).simulate('click'); @@ -531,11 +531,11 @@ describe('RangeCalendar', () => { }); it('controlled value works correctly', () => { - const wrapper = mount(); + const wrapper = mount(); const initialValue = wrapper.state('value'); expect(initialValue[0].isSame(initialValue[1], 'month')).toBe(true); - wrapper.setProps({ value: [dayjs(), dayjs()] }); + wrapper.setProps({ value: [moment(), moment()] }); const updatedValue = wrapper.state('value'); expect(updatedValue[0].isSame(updatedValue[1], 'month')).toBe(true); }); @@ -545,7 +545,7 @@ describe('RangeCalendar', () => { class Demo extends React.Component { state = { mode: ['month', 'month'], - value: [dayjs().add(-1, 'day'), dayjs()], + value: [moment().add(-1, 'day'), moment()], }; handlePanelChange = (value, mode) => { @@ -579,7 +579,7 @@ describe('RangeCalendar', () => { it('selected item style works correctly with mode year', () => { class Demo extends React.Component { state = { - value: [dayjs().add(-1, 'year'), dayjs()], + value: [moment().add(-1, 'year'), moment()], }; handlePanelChange = (value) => { @@ -635,8 +635,8 @@ describe('RangeCalendar', () => { }); it('controlled hoverValue changes', () => { - const start = dayjs(); - const end = dayjs().add(2, 'day'); + const start = moment(); + const end = moment().add(2, 'day'); const wrapper = mount(); const nextEnd = end.clone().add(2, 'day'); wrapper.setProps({ hoverValue: [start, nextEnd] }); @@ -644,8 +644,8 @@ describe('RangeCalendar', () => { }); it('controlled selectedValue changes', () => { - const start = dayjs(); - const end = dayjs().add(2, 'day'); + const start = moment(); + const end = moment().add(2, 'day'); const wrapper = mount(); const nextEnd = end.clone().add(2, 'day'); wrapper.setProps({ selectedValue: [start, nextEnd] }); @@ -661,8 +661,8 @@ describe('RangeCalendar', () => { beforeEach(() => { handleHoverChange = jest.fn(); - start = dayjs(); - end = dayjs().add(2, 'day'); + start = moment(); + end = moment().add(2, 'day'); wrapper = mount(); }); @@ -683,7 +683,7 @@ describe('RangeCalendar', () => { let keyDownEvent = 0; const wrapper = mount( keyDownEvent = 1} @@ -759,7 +759,7 @@ describe('RangeCalendar', () => { }); it('change input trigger calendar close', () => { - const value = [dayjs(), dayjs().add(1, 'months')]; + const value = [moment(), moment().add(1, 'months')]; const onSelect = jest.fn(); const wrapper = mount( @@ -786,7 +786,7 @@ describe('RangeCalendar', () => { it('date mode should not display same month', () => { const FORMAT = 'YYYY-MM-DD'; - const sameDay = dayjs('2000-01-01'); + const sameDay = moment('2000-01-01'); const wrapper = mount(); // Should in different month @@ -812,7 +812,7 @@ describe('RangeCalendar', () => { mode={['time', 'time']} timePicker={ } />, From 22d15b6b679727735301567bc15502c0bf6613e6 Mon Sep 17 00:00:00 2001 From: GongFlying <150640661+gzcqqqqqqqq1@users.noreply.github.com> Date: Wed, 28 May 2025 13:44:20 +0800 Subject: [PATCH 38/41] Time algorithm adjustment --- src/date/DateInput.js | 204 ++++++------------------------------------ src/util/index.js | 125 +------------------------- 2 files changed, 29 insertions(+), 300 deletions(-) diff --git a/src/date/DateInput.js b/src/date/DateInput.js index ab90c4b09..5a0e16ec4 100644 --- a/src/date/DateInput.js +++ b/src/date/DateInput.js @@ -4,11 +4,7 @@ import PropTypes from 'prop-types'; import KeyCode from 'rc-util/lib/KeyCode'; import { polyfill } from 'react-lifecycles-compat'; import moment from 'moment'; -import { - formatDate, DATE_FORMATS, currentDate, currentMonth, currentYear, - stringCurrentDate, stringCurrentMonth, formatDateLocal, hasSpecialChar, - isValidMonth, isValidDay, fullValidYear, getDateFormatByStr, isCurrentYear, -} from '../util'; +import { formatDate, DATE_FORMATS } from '../util'; let cachedSelectionStart; let cachedSelectionEnd; @@ -30,19 +26,18 @@ class DateInput extends React.Component { selectedValue: PropTypes.object, clearIcon: PropTypes.node, inputMode: PropTypes.string, - showHourAndMinute: PropTypes.bool, onChangeCananderIput: PropTypes.func, } constructor(props) { super(props); const selectedValue = props.selectedValue; - - const formatPrefix = this.props.format[0].slice(0, this.props.format[0].indexOf(' ')); + const formatPrefix = this.props.format[0]; let delimiter; - if (formatPrefix === DATE_FORMATS.Germany_Russia_etc) { + if (formatPrefix === DATE_FORMATS.Germany_Russia_etc || + formatPrefix === DATE_FORMATS.Germany_Russia_etcAndTime) { delimiter = '.'; - } else if (formatPrefix === DATE_FORMATS.ISO) { + } else if (formatPrefix === DATE_FORMATS.ISO || formatPrefix === DATE_FORMATS.ISOAndTime) { delimiter = '-'; } else { delimiter = '/'; @@ -73,11 +68,9 @@ class DateInput extends React.Component { onInputChange = (event) => { const str = event.target.value; - const { disabledDate, showHourAndMinute, onChange, selectedValue } = this.props; - const cananderStr = this.normalizeDateInput(str, showHourAndMinute); - const parts = formatDateLocal(cananderStr, this.state.localeFormat); + const { disabledDate, format, onChange, selectedValue } = this.props; - this.setState({ cananderIput: cananderStr }); + this.setState({ cananderIput: str }); // 没有内容,合法并直接退出 if (!str) { onChange(null); @@ -86,11 +79,7 @@ class DateInput extends React.Component { } // 不合法直接退出 - let format = getDateFormatByStr(cananderStr, this.state.localeFormat); - if (/\d{1,2}:\d{2}$/.test(cananderStr) && showHourAndMinute) { - format += ' HH:mm'; - } - const parsed = moment(cananderStr, format); + const parsed = moment(str, format); let value = this.props.value.clone(); value = value @@ -100,21 +89,6 @@ class DateInput extends React.Component { .hour(parsed.hour() || moment().hour()) .minute(parsed.minute() || moment().minute()) .second(parsed.second() || moment().second()); - if (this.state.localeFormat === DATE_FORMATS.ISO) { - if (parts[0] && parts[0].length === 4 && (parts[0].slice(0, 3) === '000' || - parts[0].slice(0, 2) === '00')) { - value.year(parts[0]); - } - } - if (this.state.localeFormat === DATE_FORMATS.European || - this.state.localeFormat === DATE_FORMATS.US || - this.state.localeFormat === DATE_FORMATS.Germany_Russia_etc - ) { - if (parts[2] && parts[2].length === 4 && (parts[2].slice(0, 3) === '000' || - parts[2].slice(0, 2) === '00')) { - value.year(parts[2]); - } - } if (!value || (disabledDate && disabledDate(value))) { this.setState({ str }); return; @@ -165,19 +139,30 @@ class DateInput extends React.Component { const parts = timeStr.split(state.delimiter); const timeParts = formatDate(selectedValue, nextProps.format).split(' ')[1]; if (state.localeFormat === DATE_FORMATS.ISO) { - if (parts[0].length > 0) { - newState = { str: `${parts[0].padStart(4, 0)}-${parts[1]}-${parts[2]} ${timeParts}` }; + if (parts.length === 3) { + newState = { str: `${parts[0].padStart(4, 0)}-${parts[1]}-${parts[2]}` }; + } + } else if (state.localeFormat === DATE_FORMATS.ISOAndTime) { + if (parts.length === 3) { + newState = { str: `${parts[0].padStart(4, 0)}-${parts[1]}-${parts[2]} ${timeParts && timeParts}` };// eslint-disable-line max-len } } else if (state.localeFormat === DATE_FORMATS.US) { if (parts.length === 3) { - newState = { str: `${Number(parts[0])}/${Number(parts[1])} - /${parts[2].padStart(4, 0)} ${timeParts}` }; + newState = { str: `${Number(parts[0])}/${Number(parts[1])}/${parts[2].padStart(4, 0)}` }; + } + } else if (state.localeFormat === DATE_FORMATS.USAndTime) { + if (parts.length === 3) { + newState = { str: `${Number(parts[0])}/${Number(parts[1])}/${parts[2].padStart(4, 0)} ${timeParts && timeParts}` };// eslint-disable-line max-len } } else if (state.localeFormat === DATE_FORMATS.European || state.localeFormat === DATE_FORMATS.Germany_Russia_etc) { if (parts.length === 3) { - newState = { str: `${Number(parts[0])}${state.delimiter}${Number(parts[1])} - ${state.delimiter}${parts[2].padStart(4, 0)} ${timeParts}` }; + newState = { str: `${Number(parts[0])}${state.delimiter}${Number(parts[1])}${state.delimiter}${parts[2].padStart(4, 0)}` };// eslint-disable-line max-len + } + } else if (state.localeFormat === DATE_FORMATS.EuropeanAndTime || + state.localeFormat === DATE_FORMATS.Germany_Russia_etcAndTime) { + if (parts.length === 3) { + newState = { str: `${Number(parts[0])}${state.delimiter}${Number(parts[1])}${state.delimiter}${parts[2].padStart(4, 0)} ${timeParts && timeParts}` };// eslint-disable-line max-len } } } @@ -192,145 +177,6 @@ class DateInput extends React.Component { return ReactDOM.findDOMNode(this); } - normalizeDateInput(str, showHourAndMinute) { - let day; - let month; - let year; - const parts = formatDateLocal(str, this.state.localeFormat, DATE_FORMATS); - const delimiter = this.state.delimiter; - const hasSpecial = hasSpecialChar(str); - if (this.state.localeFormat === DATE_FORMATS.ISO) { - const numStr = str.replace(/[^0-9]/g, ''); - if (numStr.length === 7) { - year = numStr.slice(0, 4); - month = numStr.slice(4, 6).padStart(2, '0'); - day = numStr.slice(6, 7).padStart(2, '0'); - if (!isValidDay(day)) { - return `${year}-${stringCurrentMonth}- - ${stringCurrentDate} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; - } - return `${year}-${month}-${day}`; - } - if (hasSpecial) { - year = fullValidYear(parts[0]); - month = Number(parts[1]); - day = Number(parts[2]); - if (month >= 1 && month <= 12) { - if (isValidDay(day)) { - return `${year}-${String(month).padStart(2, '0')}- - ${String(day).padStart(2, '0')} ${showHourAndMinute && - `${parts[3]}:${parts[4]}`}`; - } - return `${year}-${String(month).padStart(2, '0')}- - 01 ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; - } - if ((month >= 13 || month < 1) && isNaN(day)) { - return `${year}-${stringCurrentMonth}- - ${stringCurrentDate} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; - } - if (!month && !day) { - return `${year}-01-01 ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; - } - } - if (str.length >= 1 && str.length <= 8) { - year = fullValidYear(str.slice(0, 4)); - month = str.slice(4, 6); - day = Number(str.slice(6, 8)); - if (str.length === 5 && Number(month) < 1) { - return `${year}-${stringCurrentMonth}- - ${stringCurrentDate} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; - } - if ((str.length === 6 && Number(month) < 1)) { - return `${year}-${stringCurrentMonth}- - ${stringCurrentDate} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; - } - if ((str.length === 7)) { - if (!isValidDay(day)) { - return `${year}-${String(isValidMonth(month)).padStart(2, '0')}- - ${stringCurrentDate} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; - } - return `${year}-${String(isValidMonth(month)).padStart(2, '0')}- - ${String(day).padStart(2, '0')} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; - } - if (str.length === 8) { - if (!isValidDay(day)) { - return `${isCurrentYear(year, month, day)}- - ${String(isValidMonth(month)).padStart(2, '0')} - -${stringCurrentDate} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; - } - return `${isCurrentYear(year, month, day)}- - ${String(isValidMonth(month)).padStart(2, '0')} - -${String(day).padStart(2, '0')} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; - } - if (Number(month) >= 1 && Number(month) <= 12 && isValidDay(day)) { - return `${year}-${month.padStart(2, '0')}- - ${String(day).padStart(2, '0')} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; - } - return `${year}- - ${month ? month.padStart(2, '0') : '01'}- - ${day ? - String(day).padStart(2, '0') : - '01'} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; - } - return `${currentYear}/${stringCurrentMonth}/${stringCurrentDate}`; - } - if (this.state.localeFormat === DATE_FORMATS.US) { - if (hasSpecial) { - month = Number(parts[0]); - day = Number(parts[1]); - year = fullValidYear(parts[2]); - if (month >= 1 && month <= 12 && isValidDay(day)) { - return `${month}/${day}/${year} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; - } - } - if (str.length >= 1 && str.length <= 8) { - month = Number(str.slice(0, 2)); - day = Number(str.slice(2, 4)); - year = fullValidYear(str.slice(4, str.length)); - if (month >= 1 && month <= 12) { - if (isValidDay(day)) { - return `${month}/${day}/${year} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; - } - if (!day) { - return `${month}/1/ - ${year} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; - } - return `${month}/${day}/ - ${year} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; - } - } - return `${currentMonth}/ - ${currentDate}/ - ${currentYear} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; - } - if (this.state.localeFormat === DATE_FORMATS.European || - this.state.localeFormat === DATE_FORMATS.Germany_Russia_etc) { - if (hasSpecial) { - month = parts[1]; - year = fullValidYear(parts[2]); - if (isValidDay(parts[0]) && Number(month) >= 1 && Number(month) <= 12) { - return `${Number(parts[0])}${delimiter}${Number(month)} - ${delimiter}${year} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; - } - return `${currentDate}${delimiter}${currentMonth} - ${delimiter}${currentYear} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; - } - if (str.length >= 1 && str.length <= 8) { - day = Number(str.slice(0, 2)); - const monthStr = str.slice(2, 4); - month = isValidMonth(monthStr); - const yearStr = str.slice(4, str.length); - year = fullValidYear(yearStr); - if (isValidDay(day)) { - return `${Number(day)}${delimiter}${Number(month)} - ${delimiter}${year} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; - } - } - return `${currentDate}${delimiter}${currentMonth} - ${delimiter}${currentYear} ${showHourAndMinute && `${parts[3]}:${parts[4]}`}`; - } - } - focus = () => { if (dateInputInstance) { dateInputInstance.focus(); diff --git a/src/util/index.js b/src/util/index.js index 3bc181d56..88f7dc3db 100644 --- a/src/util/index.js +++ b/src/util/index.js @@ -1,17 +1,14 @@ import moment from 'moment'; -export const currentDate = moment().date(); -export const currentMonth = moment().month() + 1; -export const currentYear = moment().year(); -export const nowTime = moment().format('HH:mm'); -export const stringCurrentDate = String(currentDate).padStart(2, '0'); -export const stringCurrentMonth = String(currentMonth).padStart(2, '0'); - export const DATE_FORMATS = { ISO: 'YYYY-MM-DD', + ISOAndTime: 'YYYY-MM-DD HH:mm', US: 'M/D/YYYY', + USAndTime: 'M/D/YYYY HH:mm', European: 'DD/MM/YYYY', + EuropeanAndTime: 'DD/MM/YYYY HH:mm', Germany_Russia_etc: 'DD.MM.YYYY', + Germany_Russia_etcAndTime: 'DD.MM.YYYY HH:mm', }; const defaultDisabledTime = { @@ -116,117 +113,3 @@ export function formatDate(value, format) { return value.format(format); } - -export function formatDateLocal(formatStr, format) { - const str = formatStr || ''; - let cleanStr; - switch (format) { - case DATE_FORMATS.ISO: - cleanStr = str.replace(/[^0-9]+/g, '-'); - return cleanStr.split('-').filter(Boolean).map(String); - case DATE_FORMATS.US: - case DATE_FORMATS.European: - cleanStr = str.replace(/[^0-9]+/g, '/'); - return cleanStr.split('/').filter(Boolean).map(String); - case DATE_FORMATS.Germany_Russia_etc: - cleanStr = str.replace(/[^0-9]+/g, '.'); - return cleanStr.split('.').filter(Boolean).map(String); - default: - return []; - } -} - -export function hasSpecialChar(str) { - const matches = str.match(/[^0-9]/g); - return matches ? matches.length : 0; -} - -export function isValidMonth(monthStr) { - if (typeof monthStr === 'undefined' || monthStr === null) return currentMonth; - if (!/^\d+$/.test(Number(monthStr))) return currentMonth; - const month = Number(monthStr); - if (month >= 1 && month <= 12) { - return monthStr; - } - return currentMonth; -} - -export function isValidDay(dayStr) { - if (!/^\d+$/.test(dayStr)) return false; - const day = Number(dayStr); - if ([1, 3, 5, 7, 8, 10, 12].includes(currentMonth)) { - return day >= 1 && day <= 31; - } - if ([4, 6, 9, 11].includes(currentMonth)) { - return day >= 1 && day <= 30; - } - if (currentMonth === 2) { - const isLeapYear = (year) => { - return (year % 4 === 0 && year % 100 !== 0) || (year % 400 === 0); - }; - const year = currentYear; - if (isLeapYear(year)) { - return day >= 1 && day <= 29; - } - return day >= 1 && day <= 28; - } -} - -export function fullValidYear(yearStr) { - const year = yearStr; - if (!year || isNaN(year)) return currentYear; - if (year.length === 2) { - if (Number(year) >= 0 && Number(year) < 69) { - return year ? `20${year}` : currentYear; - } else if (Number(year) >= 69 && Number(year) < 100) { - return year ? `19${year}` : currentYear; - } - } - if (year.length === 4) { - return year; - } - return year ? year.padStart(4, '0') : currentYear; -} - -export function getDateFormatByStr(str, format) { - const cananderStr = str || ''; - const parts = cananderStr.split('/'); - if (parts.length !== 3) return format; - const delimiter = format === DATE_FORMATS.European ? '/' : '.'; - if (format === DATE_FORMATS.ISO) { - return DATE_FORMATS.ISO; - } - if (format === DATE_FORMATS.US) { - return DATE_FORMATS.US; - } - if ((format === DATE_FORMATS.European) || (format === DATE_FORMATS.Germany_Russia_etc)) { - const [day, month] = parts; - const dayLen = day.length; - const monthLen = month.length; - if (dayLen === 2 && monthLen === 2) { - return `DD${delimiter}MM${delimiter}YYYY`; - } else if (dayLen === 2 && monthLen === 1) { - return `DD${delimiter}M${delimiter}YYYY`; - } else if (dayLen === 1 && monthLen === 2) { - return `D${delimiter}MM${delimiter}YYYY`; - } else if (dayLen === 1 && monthLen === 1) { - return `D${delimiter}M${delimiter}YYYY`; - } - } - return format; -} - -export function isCurrentYear(year, month, day) { - return ( - Number(month) >= 1 && - Number(month) <= 12 && - Number(day) >= 1 && - Number(day) <= 31 - ) - ? year - : currentYear; -} - -export function isShowTimePicker(cananderStr) { - return `${cananderStr} `; -} From 64eea29b941684ce4fafb03af585e9601dfc0853 Mon Sep 17 00:00:00 2001 From: GongFlying <150640661+gzcqqqqqqqq1@users.noreply.github.com> Date: Wed, 28 May 2025 13:47:27 +0800 Subject: [PATCH 39/41] Time algorithm adjustment --- src/util/dayjs.js | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 src/util/dayjs.js diff --git a/src/util/dayjs.js b/src/util/dayjs.js deleted file mode 100644 index 2b4c0607c..000000000 --- a/src/util/dayjs.js +++ /dev/null @@ -1,17 +0,0 @@ -import moment from 'moment'; -import localeData from 'moment/plugin/localeData'; -import weekOfYear from 'moment/plugin/weekOfYear'; -import utc from 'moment/plugin/utc'; -import advancedFormat from 'moment/plugin/advancedFormat'; -import customParseFormat from 'moment/plugin/customParseFormat'; -import badMutable from 'moment/plugin/badMutable'; -import 'moment/locale/zh-cn'; -import 'moment/locale/en-gb'; - -moment.extend(localeData); -moment.extend(weekOfYear); -moment.extend(utc); -moment.extend(advancedFormat); -moment.extend(customParseFormat); -moment.extend(badMutable); -export default moment; From a26175ed9c8574c9d3b7b25cba487d08bfdf1e4a Mon Sep 17 00:00:00 2001 From: GongFlying <150640661+gzcqqqqqqqq1@users.noreply.github.com> Date: Thu, 29 May 2025 09:48:38 +0800 Subject: [PATCH 40/41] datepicker fix pla --- index.d.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/index.d.ts b/index.d.ts index 55f6cfc71..6bbca0151 100644 --- a/index.d.ts +++ b/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/react-component/calendar import * as React from 'react'; -import {moment} from 'moment'; +import {Moment} from 'moment'; export type Mode = 'time' | 'date' | 'month' | 'year' | 'decade'; @@ -12,9 +12,9 @@ export interface Props { prefixCls?: string; className?: string; style?: React.CSSProperties; - defaultValue?: moment; - value?: moment; - selectedValue?: moment; + defaultValue?: Moment; + value?: Moment; + selectedValue?: Moment; mode?: Mode; locale?: object; format?: string | string[]; @@ -22,18 +22,18 @@ export interface Props { showWeekNumber?: boolean; showToday?: boolean; showOk?: boolean; - onSelect?: ( date: moment ) => void; + onSelect?: ( date: Moment ) => void; onOk?: () => void; onKeyDown?: () => void; onClickRightPanelTime?: () => void; timePicker?: React.ReactNode; dateInputPlaceholder?: string; onClear?: () => void; - onChange?: ( date: moment | null ) => void; - onPanelChange?: ( date: moment | null, mode: Mode ) => void; - disabledDate?: ( current: moment | undefined ) => boolean; - disabledTime?: ( current: moment | undefined ) => object; - dateRender?: ( current: moment, value: moment ) => React.ReactNode; + onChange?: ( date: Moment | null ) => void; + onPanelChange?: ( date: Moment | null, mode: Mode ) => void; + disabledDate?: ( current: Moment | undefined ) => boolean; + disabledTime?: ( current: Moment | undefined ) => object; + dateRender?: ( current: Moment, value: Moment ) => React.ReactNode; renderFooter?: () => React.ReactNode; renderSidebar?: () => React.ReactNode; inputMode?: string; From 177f071f000c0e2dc3e8c7584610156cd40d8531 Mon Sep 17 00:00:00 2001 From: GongFlying <150640661+gzcqqqqqqqq1@users.noreply.github.com> Date: Thu, 29 May 2025 13:16:24 +0800 Subject: [PATCH 41/41] rm code --- index.d.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/index.d.ts b/index.d.ts index 6bbca0151..c1fcad064 100644 --- a/index.d.ts +++ b/index.d.ts @@ -4,7 +4,6 @@ // Definitions: https://github.com/react-component/calendar import * as React from 'react'; -import {Moment} from 'moment'; export type Mode = 'time' | 'date' | 'month' | 'year' | 'decade'; @@ -12,9 +11,9 @@ export interface Props { prefixCls?: string; className?: string; style?: React.CSSProperties; - defaultValue?: Moment; - value?: Moment; - selectedValue?: Moment; + defaultValue?: Object; + value?: Object; + selectedValue?: object; mode?: Mode; locale?: object; format?: string | string[]; @@ -22,18 +21,18 @@ export interface Props { showWeekNumber?: boolean; showToday?: boolean; showOk?: boolean; - onSelect?: ( date: Moment ) => void; + onSelect?: ( date: object ) => void; onOk?: () => void; onKeyDown?: () => void; onClickRightPanelTime?: () => void; timePicker?: React.ReactNode; dateInputPlaceholder?: string; onClear?: () => void; - onChange?: ( date: Moment | null ) => void; - onPanelChange?: ( date: Moment | null, mode: Mode ) => void; - disabledDate?: ( current: Moment | undefined ) => boolean; - disabledTime?: ( current: Moment | undefined ) => object; - dateRender?: ( current: Moment, value: Moment ) => React.ReactNode; + onChange?: ( date: object | null ) => void; + onPanelChange?: ( date: Object | null, mode: Mode ) => void; + disabledDate?: ( current: object | undefined ) => boolean; + disabledTime?: ( current: object | undefined ) => object; + dateRender?: ( current: object, value: object ) => React.ReactNode; renderFooter?: () => React.ReactNode; renderSidebar?: () => React.ReactNode; inputMode?: string;