Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Issue #2810: Inconsistent Behavior with add after startOf call #2813

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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