Skip to content

Commit 6c9047e

Browse files
fix: timezome update logic based on timezone availability in object
1 parent c1d37ff commit 6c9047e

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/plugin/timezone/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ export default (o, c, d) => {
123123

124124
const oldStartOf = proto.startOf
125125
proto.startOf = function (units, startOf) {
126-
if (!this.$x || !this.$x.$timezone) {
126+
if (this.$x && this.$x.$timezone) {
127+
// timezone information is kept in $x: { timezone: "utc"}
127128
return oldStartOf.call(this, units, startOf)
128129
}
129130

test/timezone.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ it('Diff (DST)', () => {
4545
it('UTC add day in DST', () => {
4646
const testDate = '2019-03-10'
4747
const dayTest = dayjs(testDate)
48-
.utc()
48+
.tz('utc')
4949
.startOf('day')
5050
const momentTest = moment(testDate)
5151
.utc()
5252
.startOf('day')
53-
expect(dayTest.add(1, 'day').format())
53+
expect(dayTest.add(1, 'day').format('YYYY-MM-DDTHH:mm:ss[Z]'))
5454
.toBe(momentTest.clone().add(1, 'day').format())
55-
expect(dayTest.add(2, 'day').format())
55+
expect(dayTest.add(2, 'day').format('YYYY-MM-DDTHH:mm:ss[Z]'))
5656
.toBe(momentTest.clone().add(2, 'day').format())
5757
})
5858

0 commit comments

Comments
 (0)