File tree 2 files changed +11
-1
lines changed
2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ const dayjs = function (date, c) {
50
50
const wrapper = ( date , instance ) =>
51
51
dayjs ( date , {
52
52
locale : instance . $L ,
53
- utc : instance . $u ,
53
+ utc : instance . $offset !== 0 && instance . $ u,
54
54
x : instance . $x ,
55
55
$offset : instance . $offset // todo: refactor; do not use this.$offset in you code
56
56
} )
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import moment from 'moment'
3
3
import dayjs from '../src'
4
4
import timezone from '../src/plugin/timezone'
5
5
import utc from '../src/plugin/utc'
6
+ import '../src/locale/en'
6
7
7
8
dayjs . extend ( utc )
8
9
dayjs . extend ( timezone )
@@ -80,3 +81,12 @@ it('UTC diff in DST', () => {
80
81
expect ( day1 . diff ( day2 , 'd' ) )
81
82
. toBe ( - 3 )
82
83
} )
84
+
85
+ it ( 'TZ with Locale' , ( ) => {
86
+ const test1 = dayjs ( '2000-01-01T09:00:00+09:00' ) . tz ( 'Asia/Seoul' ) . locale ( 'en' )
87
+ expect ( test1 . hour ( ) ) . toBe ( 9 )
88
+ const test2 = dayjs ( '2000-01-01T09:00:00+09:00' ) . tz ( 'Asia/Hong_Kong' ) . locale ( 'en' )
89
+ expect ( test2 . hour ( ) ) . toBe ( 8 )
90
+ const test3 = dayjs ( '2000-01-01T09:00:00+09:00' ) . tz ( 'Etc/UTC' ) . locale ( 'en' )
91
+ expect ( test3 . hour ( ) ) . toBe ( 0 )
92
+ } )
You can’t perform that action at this time.
0 commit comments