@@ -2,6 +2,7 @@ import MockDate from 'mockdate'
2
2
import moment from 'moment'
3
3
import dayjs from '../../src'
4
4
import advancedFormat from '../../src/plugin/advancedFormat'
5
+ import isoWeek from '../../src/plugin/isoWeek'
5
6
import weekOfYear from '../../src/plugin/weekOfYear'
6
7
import weekYear from '../../src/plugin/weekYear'
7
8
import timezone from '../../src/plugin/timezone'
@@ -10,6 +11,7 @@ import '../../src/locale/zh-cn'
10
11
11
12
dayjs . extend ( utc )
12
13
dayjs . extend ( timezone )
14
+ dayjs . extend ( isoWeek )
13
15
dayjs . extend ( weekYear )
14
16
dayjs . extend ( weekOfYear )
15
17
dayjs . extend ( advancedFormat )
@@ -82,11 +84,29 @@ it('Format Week of Year wo', () => {
82
84
. toBe ( moment ( d ) . locale ( 'zh-cn' ) . format ( 'wo' ) )
83
85
} )
84
86
87
+ it ( 'Format Week of Year wo' , ( ) => {
88
+ const d = '2018-12-01'
89
+ expect ( dayjs ( d ) . format ( 'wo' ) ) . toBe ( moment ( d ) . format ( 'wo' ) )
90
+ expect ( dayjs ( d ) . locale ( 'zh-cn' ) . format ( 'wo' ) )
91
+ . toBe ( moment ( d ) . locale ( 'zh-cn' ) . format ( 'wo' ) )
92
+ } )
93
+
85
94
it ( 'Format Week Year gggg' , ( ) => {
86
95
const d = '2018-12-31'
87
96
expect ( dayjs ( d ) . format ( 'gggg' ) ) . toBe ( moment ( d ) . format ( 'gggg' ) )
88
97
} )
89
98
99
+ it ( 'Format Iso Week Year GGGG' , ( ) => {
100
+ const d = '2021-01-01'
101
+ expect ( dayjs ( d ) . format ( 'GGGG' ) ) . toBe ( moment ( d ) . format ( 'GGGG' ) )
102
+ } )
103
+
104
+ it ( 'Format Iso Week of Year' , ( ) => {
105
+ const d = '2021-01-01'
106
+ expect ( dayjs ( d ) . format ( 'W' ) ) . toBe ( moment ( d ) . format ( 'W' ) )
107
+ expect ( dayjs ( d ) . format ( 'WW' ) ) . toBe ( moment ( d ) . format ( 'WW' ) )
108
+ } )
109
+
90
110
it ( 'Format offsetName z zzz' , ( ) => {
91
111
const dtz = dayjs . tz ( '2012-03-11 01:59:59' , 'America/New_York' )
92
112
expect ( dtz . format ( 'z' ) ) . toBe ( 'EST' )
@@ -99,6 +119,11 @@ it('Skips format strings inside brackets', () => {
99
119
expect ( dayjs ( ) . format ( '[Q]' ) ) . toBe ( 'Q' )
100
120
expect ( dayjs ( ) . format ( '[Do]' ) ) . toBe ( 'Do' )
101
121
expect ( dayjs ( ) . format ( '[gggg]' ) ) . toBe ( 'gggg' )
122
+ expect ( dayjs ( ) . format ( '[GGGG]' ) ) . toBe ( 'GGGG' )
123
+ expect ( dayjs ( ) . format ( '[w]' ) ) . toBe ( 'w' )
124
+ expect ( dayjs ( ) . format ( '[ww]' ) ) . toBe ( 'ww' )
125
+ expect ( dayjs ( ) . format ( '[W]' ) ) . toBe ( 'W' )
126
+ expect ( dayjs ( ) . format ( '[WW]' ) ) . toBe ( 'WW' )
102
127
expect ( dayjs ( ) . format ( '[wo]' ) ) . toBe ( 'wo' )
103
128
expect ( dayjs ( ) . format ( '[k]' ) ) . toBe ( 'k' )
104
129
expect ( dayjs ( ) . format ( '[kk]' ) ) . toBe ( 'kk' )
0 commit comments