Skip to content

Commit

Permalink
fix: timezome update logic based on timezone availability in object
Browse files Browse the repository at this point in the history
  • Loading branch information
github-roushan committed Jan 17, 2025
1 parent c1d37ff commit 6c9047e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/plugin/timezone/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ export default (o, c, d) => {

const oldStartOf = proto.startOf
proto.startOf = function (units, startOf) {
if (!this.$x || !this.$x.$timezone) {
if (this.$x && this.$x.$timezone) {
// timezone information is kept in $x: { timezone: "utc"}
return oldStartOf.call(this, units, startOf)
}

Expand Down
6 changes: 3 additions & 3 deletions test/timezone.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ it('Diff (DST)', () => {
it('UTC add day in DST', () => {
const testDate = '2019-03-10'
const dayTest = dayjs(testDate)
.utc()
.tz('utc')
.startOf('day')
const momentTest = moment(testDate)
.utc()
.startOf('day')
expect(dayTest.add(1, 'day').format())
expect(dayTest.add(1, 'day').format('YYYY-MM-DDTHH:mm:ss[Z]'))
.toBe(momentTest.clone().add(1, 'day').format())
expect(dayTest.add(2, 'day').format())
expect(dayTest.add(2, 'day').format('YYYY-MM-DDTHH:mm:ss[Z]'))
.toBe(momentTest.clone().add(2, 'day').format())
})

Expand Down

0 comments on commit 6c9047e

Please sign in to comment.