generated from react-component/footer
-
-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
139 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import moment, { Moment } from 'moment'; | ||
import { GenerateConfig } from '.'; | ||
|
||
const generateConfig: GenerateConfig<Moment> = { | ||
// get | ||
getFirstDateOfMonth: date => { | ||
const clone = date.clone(); | ||
clone.date(1); | ||
return clone; | ||
}, | ||
getLastDateOfMonth: date => { | ||
const clone = date.clone(); | ||
clone | ||
.date(1) | ||
.add(1, 'month') | ||
.subtract(1, 'day'); | ||
return clone; | ||
}, | ||
getNow: () => moment(), | ||
getWeekDay: date => date.weekday(), | ||
getYear: date => date.year(), | ||
getMonth: date => date.month(), | ||
getDate: date => date.date(), | ||
getHour: date => date.hour(), | ||
getMinute: date => date.minute(), | ||
getSecond: date => date.second(), | ||
|
||
// set | ||
addYear: (date, diff) => { | ||
const clone = date.clone(); | ||
clone.add(diff, 'year'); | ||
return clone; | ||
}, | ||
addMonth: (date, diff) => { | ||
const clone = date.clone(); | ||
clone.add(diff, 'month'); | ||
return clone; | ||
}, | ||
addDate: (date, diff) => { | ||
const clone = date.clone(); | ||
clone.add(diff, 'day'); | ||
return clone; | ||
}, | ||
setYear: (date, year) => { | ||
const clone = date.clone(); | ||
clone.year(year); | ||
return clone; | ||
}, | ||
setMonth: (date, month) => { | ||
const clone = date.clone(); | ||
clone.month(month); | ||
return clone; | ||
}, | ||
setDate: (date, num) => { | ||
const clone = date.clone(); | ||
clone.date(num); | ||
return clone; | ||
}, | ||
setHour: (date, hour) => { | ||
const clone = date.clone(); | ||
clone.hour(hour); | ||
return clone; | ||
}, | ||
setMinute: (date, minute) => { | ||
const clone = date.clone(); | ||
clone.minute(minute); | ||
return clone; | ||
}, | ||
setSecond: (date, second) => { | ||
const clone = date.clone(); | ||
clone.second(second); | ||
return clone; | ||
}, | ||
|
||
locale: { | ||
getWeekFirstDay: locale => { | ||
const date = moment().locale(locale); | ||
return date.localeData().firstDayOfWeek(); | ||
}, | ||
getWeek: (locale, date) => { | ||
const clone = date.clone(); | ||
clone.locale(locale); | ||
return clone.week(); | ||
}, | ||
getShortWeekDays: locale => { | ||
const date = moment().locale(locale); | ||
return date.localeData().weekdaysMin(); | ||
}, | ||
getShortMonths: locale => { | ||
const date = moment().locale(locale); | ||
return date.localeData().monthsShort(); | ||
}, | ||
format: (locale, date, format) => { | ||
const clone = date.clone(); | ||
clone.locale(locale); | ||
return clone.format(format); | ||
}, | ||
parse: (locale, text, formats) => { | ||
for (let i = 0; i < formats.length; i += 1) { | ||
let format = formats[i]; | ||
let strictMode = true; | ||
|
||
if (format.includes('o')) { | ||
format = format.replace(/o/g, ''); | ||
strictMode = false; | ||
} | ||
|
||
const date = moment(text, format, locale, strictMode); | ||
if (date.isValid()) { | ||
return date; | ||
} | ||
} | ||
return null; | ||
}, | ||
}, | ||
}; | ||
|
||
export default generateConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a48d57a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to following URLs: