File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 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) {
5050const wrapper = ( date , instance ) =>
5151 dayjs ( date , {
5252 locale : instance . $L ,
53- utc : instance . $u ,
53+ utc : instance . $offset !== 0 && instance . $ u,
5454 x : instance . $x ,
5555 $offset : instance . $offset // todo: refactor; do not use this.$offset in you code
5656 } )
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import moment from 'moment'
33import dayjs from '../src'
44import timezone from '../src/plugin/timezone'
55import utc from '../src/plugin/utc'
6+ import '../src/locale/en'
67
78dayjs . extend ( utc )
89dayjs . extend ( timezone )
@@ -80,3 +81,12 @@ it('UTC diff in DST', () => {
8081 expect ( day1 . diff ( day2 , 'd' ) )
8182 . toBe ( - 3 )
8283} )
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