Skip to content

fix(settings): display birthday correctly regardless of browsers timezone#61586

Open
odzhychko wants to merge 2 commits into
masterfrom
BirthdaySection-timezone
Open

fix(settings): display birthday correctly regardless of browsers timezone#61586
odzhychko wants to merge 2 commits into
masterfrom
BirthdaySection-timezone

Conversation

@odzhychko

@odzhychko odzhychko commented Jun 25, 2026

Copy link
Copy Markdown

Summary

Display birthday correctly regardless of browsers timezone.

Before

Screen.Recording.2026-06-25.at.09.48.23.mov

After

Screen.Recording.2026-06-25.at.09.50.04.mov

Checklist

@odzhychko odzhychko added this to the Nextcloud 34.0.2 milestone Jun 25, 2026
@odzhychko odzhychko added bug 3. to review Waiting for reviews labels Jun 25, 2026
`savePrimaryAccountProperty` does only allow  `string | boolean`.
Incidentally, relying on `@nextcloud/axios` default serialization, `Date`s where serialized using `toISOString`.
See https://github.com/axios/axios/blob/a7d7a714498452e611943d9d8e5c2ed8b00aa6b9/lib/helpers/toFormData.js#L134

This change corrects the usage of `savePrimaryAccountProperty` and makes serialization explicit.

Signed-off-by: Oleksandr Dzhychko <hey@oleks.dev>
…zone

This also avoid shifting dates after user input.

Resolves #49828

Signed-off-by: Oleksandr Dzhychko <hey@oleks.dev>
@odzhychko odzhychko force-pushed the BirthdaySection-timezone branch from 9370ac9 to 08e0100 Compare June 25, 2026 09:05
@odzhychko

Copy link
Copy Markdown
Author

/backport to stable34

@odzhychko

Copy link
Copy Markdown
Author

/backport to stable33

@odzhychko

Copy link
Copy Markdown
Author

/backport to stable32

@odzhychko odzhychko marked this pull request as ready for review June 25, 2026 10:39
@odzhychko odzhychko requested review from a team as code owners June 25, 2026 10:39
@odzhychko odzhychko requested review from nfebe, sorbaugh and susnux and removed request for a team June 25, 2026 10:39
Comment on lines 76 to 78
get() {
return new Date(this.birthdate.value)
return birthdateValueToDate(this.birthdate.value)
},

@susnux susnux Jun 25, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer a writable computed.

- 		value: {
+ 		value() {
- 			get() {
- 				return birthdateValueToDate(this.birthdate.value)
+ 			return birthdateValueToDate(this.birthdate.value)
- 			},

Comment on lines +86 to 99
timezoneAdjustedValue: {
get() {
// example: this.birthdate.value === '1987-12-01T00:00:00.000Z' or '1987-12-01'

// example: Mon Nov 30 1987 16:00:00 GMT-0800 (Pacific Standard Time)
// `NcDateTimePickerNative` would show this as 11/30/1987
const date = this.value
const timezoneOffsetMilliseconds = date.getTimezoneOffset() * 60 * 1000
const adjustedDate = new Date(date.getTime() + timezoneOffsetMilliseconds)

// example: Tue Dec 01 1987 00:00:00 GMT-0800 (Pacific Standard Time)
// `NcDateTimePickerNative` will show this as 12/01/1987
return adjustedDate
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not writable computed, no need for the getter...

Suggested change
timezoneAdjustedValue: {
get() {
// example: this.birthdate.value === '1987-12-01T00:00:00.000Z' or '1987-12-01'
// example: Mon Nov 30 1987 16:00:00 GMT-0800 (Pacific Standard Time)
// `NcDateTimePickerNative` would show this as 11/30/1987
const date = this.value
const timezoneOffsetMilliseconds = date.getTimezoneOffset() * 60 * 1000
const adjustedDate = new Date(date.getTime() + timezoneOffsetMilliseconds)
// example: Tue Dec 01 1987 00:00:00 GMT-0800 (Pacific Standard Time)
// `NcDateTimePickerNative` will show this as 12/01/1987
return adjustedDate
},
timezoneAdjustedValue() {
// example: this.birthdate.value === '1987-12-01T00:00:00.000Z' or '1987-12-01'
// example: Mon Nov 30 1987 16:00:00 GMT-0800 (Pacific Standard Time)
// `NcDateTimePickerNative` would show this as 11/30/1987
const date = this.value
const timezoneOffsetMilliseconds = date.getTimezoneOffset() * 60 * 1000
const adjustedDate = new Date(date.getTime() + timezoneOffsetMilliseconds)
// example: Tue Dec 01 1987 00:00:00 GMT-0800 (Pacific Standard Time)
// `NcDateTimePickerNative` will show this as 12/01/1987
return adjustedDate
},

Comment thread package.json
"msw": "^2.14.6",
"sass": "^1.100.0",
"stylelint": "^17.12.0",
"timezone-mock": "^1.4.3",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not used by any migrated frontend, so this belongs into build/frontend-legacy/package.json

*/

import { mount } from '@vue/test-utils'
import timezoneMock from 'timezone-mock'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does vi.stubEnv("TZ", ...) does not work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: entered date is shifted back one day in Birthday

2 participants