fix(settings): display birthday correctly regardless of browsers timezone#61586
Open
odzhychko wants to merge 2 commits into
Open
fix(settings): display birthday correctly regardless of browsers timezone#61586odzhychko wants to merge 2 commits into
odzhychko wants to merge 2 commits into
Conversation
`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>
9370ac9 to
08e0100
Compare
Author
|
/backport to stable34 |
Author
|
/backport to stable33 |
Author
|
/backport to stable32 |
susnux
reviewed
Jun 25, 2026
Comment on lines
76
to
78
| get() { | ||
| return new Date(this.birthdate.value) | ||
| return birthdateValueToDate(this.birthdate.value) | ||
| }, |
Contributor
There was a problem hiding this comment.
This is no longer a writable computed.
- value: {
+ value() {
- get() {
- return birthdateValueToDate(this.birthdate.value)
+ return birthdateValueToDate(this.birthdate.value)
- },
susnux
reviewed
Jun 25, 2026
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 | ||
| }, |
Contributor
There was a problem hiding this comment.
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 | |
| }, |
susnux
reviewed
Jun 25, 2026
| "msw": "^2.14.6", | ||
| "sass": "^1.100.0", | ||
| "stylelint": "^17.12.0", | ||
| "timezone-mock": "^1.4.3", |
Contributor
There was a problem hiding this comment.
This is not used by any migrated frontend, so this belongs into build/frontend-legacy/package.json
susnux
reviewed
Jun 25, 2026
| */ | ||
|
|
||
| import { mount } from '@vue/test-utils' | ||
| import timezoneMock from 'timezone-mock' |
Contributor
There was a problem hiding this comment.
Does vi.stubEnv("TZ", ...) does not work?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
3. to review, feature component)stable32)