-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1164 from iamkun/dev
D2M
- Loading branch information
Showing
17 changed files
with
529 additions
and
75 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -401,5 +401,5 @@ dayjs.unix = timestamp => ( | |
|
||
dayjs.en = Ls[L] | ||
dayjs.Ls = Ls | ||
|
||
dayjs.p = {} | ||
export default dayjs |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* eslint-disable no-console */ | ||
export default (o, c, d) => { | ||
if (process.env.NODE_ENV !== 'production') { | ||
const proto = c.prototype | ||
const oldParse = proto.parse | ||
proto.parse = function (cfg) { | ||
const { date } = cfg | ||
if (typeof date === 'string' && date.length === 13) { | ||
console.warn(`To parse a Unix timestamp like ${date}, you should pass it as a Number. https://day.js.org/docs/en/parse/unix-timestamp-milliseconds`) | ||
} | ||
if (cfg.args.length >= 2 && !d.p.customParseFormat) { | ||
console.warn(`To parse a date-time string like ${date} using the given format, you should enable customParseFormat plugin first. https://day.js.org/docs/en/parse/string-format`) | ||
} | ||
return oldParse.bind(this)(cfg) | ||
} | ||
} | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import moment from 'moment' | ||
import dayjs from '../../src' | ||
import relativeTime from '../../src/plugin/relativeTime' | ||
import '../../src/locale/hu' | ||
|
||
dayjs.extend(relativeTime) | ||
|
||
it('RelativeTime: Time from X', () => { | ||
const T = [ | ||
[44.4, 'second'], // a few seconds | ||
[89.5, 'second'], // a minute | ||
[2, 'minute'], // 2 minutes | ||
[43, 'minute'], // 43 minutes | ||
[45, 'minute'], // an hour | ||
[3, 'hour'], // 3 hours | ||
[21, 'hour'], // 21 hours | ||
[1, 'day'], // a day | ||
[3, 'day'], // 3 day | ||
[25, 'day'], // 25 days | ||
[1, 'month'], // a month | ||
[2, 'month'], // 2 month | ||
[10, 'month'], // 10 month | ||
[1, 'year'], // a year | ||
[2, 'year'], // 2 year | ||
[5, 'year'], // 5 year | ||
[18, 'month'] // 2 years | ||
] | ||
|
||
T.forEach((t) => { | ||
dayjs.locale('hu') | ||
moment.locale('hu') | ||
|
||
const dayjsDay = dayjs() | ||
const momentDay = moment() | ||
|
||
const dayjsCompare = dayjs().add(t[0], t[1]) | ||
const momentCompare = moment().add(t[0], t[1]) | ||
|
||
expect(dayjsDay.from(dayjsCompare)).toBe(momentDay.from(momentCompare)) | ||
|
||
expect(dayjsDay.to(dayjsCompare)).toBe(momentDay.to(momentCompare)) | ||
|
||
expect(dayjsDay.from(dayjsCompare, true)).toBe(momentDay.from(momentCompare, true)) | ||
}) | ||
}) |
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
Oops, something went wrong.