-
-
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 #754 from iamkun/dev
D2M
- Loading branch information
Showing
15 changed files
with
148 additions
and
11 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 |
---|---|---|
|
@@ -15,9 +15,9 @@ coverage | |
# build | ||
/locale | ||
/plugin | ||
dayjs.min.js | ||
/dayjs.min.js | ||
/esm | ||
index.d.ts | ||
/index.d.ts | ||
|
||
#dev | ||
demo.js |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import MockDate from 'mockdate' | ||
import dayjs from '../../src' | ||
import advancedFormat from '../../src/plugin/advancedFormat' | ||
import '../../src/locale/sv' | ||
|
||
dayjs.extend(advancedFormat) | ||
|
||
beforeEach(() => { | ||
MockDate.set(new Date()) | ||
}) | ||
|
||
afterEach(() => { | ||
MockDate.reset() | ||
}) | ||
|
||
it('Swedish locale Do 1a not format to 1am', () => { | ||
expect(dayjs('2019-01-01').locale('sv').format('dddd Do MMMM')) | ||
.toBe('tisdag 1a januari') | ||
expect(dayjs('2019-01-02').locale('sv').format('dddd Do MMMM')) | ||
.toBe('onsdag 2a januari') | ||
}) |
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,21 @@ | ||
import moment from 'moment' | ||
import MockDate from 'mockdate' | ||
import dayjs from '../../src' | ||
import '../../src/locale/zh-cn' | ||
|
||
beforeEach(() => { | ||
MockDate.set(new Date()) | ||
}) | ||
|
||
afterEach(() => { | ||
MockDate.reset() | ||
}) | ||
|
||
it('Meridiem', () => { | ||
const dayjsObj = dayjs().locale('zh-cn') | ||
const momentObj = moment().locale('zh-cn') | ||
for (let i = 0; i <= 24; i += 1) { | ||
expect(dayjsObj.add(i, 'hour').format('A')) | ||
.toEqual(momentObj.clone().add(i, 'hour').format('A')) | ||
} | ||
}) |
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,11 @@ | ||
/// <reference path="./types.d.ts" /> | ||
|
||
declare module 'dayjs/locale/*' { | ||
namespace locale { | ||
interface Locale extends ILocale {} | ||
} | ||
|
||
const locale: locale.Locale | ||
|
||
export = locale | ||
} |
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,33 @@ | ||
declare interface ILocale { | ||
name: string | ||
weekdays?: string[] | ||
months?: string[] | ||
weekStart?: number | ||
weekdaysShort?: string[] | ||
monthsShort?: string[] | ||
weekdaysMin?: string[] | ||
ordinal?: (n: number) => number | string | ||
formats: Partial<{ | ||
LT: string | ||
LTS: string | ||
L: string | ||
LL: string | ||
LLL: string | ||
LLLL: string | ||
}> | ||
relativeTime: Partial<{ | ||
future: string | ||
past: string | ||
s: string | ||
m: string | ||
mm: string | ||
h: string | ||
hh: string | ||
d: string | ||
dd: string | ||
M: string | ||
MM: string | ||
y: string | ||
yy: string | ||
}> | ||
} |