feat(material-luxon-adapter) add option to set zone#33579
Open
laliconfigcat wants to merge 1 commit into
Open
Conversation
Add zone option to be able to change the zone through MAT_LUXON_DATE_ADAPTER_OPTIONS.
laliconfigcat
force-pushed
the
luxon-data-adapter-zone-handling
branch
from
July 23, 2026 16:46
d3acb55 to
905f8f2
Compare
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.
Add zone option to be able to change the zone through MAT_LUXON_DATE_ADAPTER_OPTIONS.
In a web app where the user can set their preferred timezone apart from local and UTC, the current implementation is not sufficient. The current UTC/local works fine, but there are use cases when it is not enough.
I added a new zone option to the MatLuxonDateAdapterOptions and it is passed everywhere in the adapter.
The main issue was with the DateRangePicker. However I gave it DateTimes that were in the desired timezone, after changing the range, the new DateTime objects were in local timezone.
Also, the today highlight was wrong with the today date that was using local timezone.
Basically the change is this in the _getOptions and some minor refactorings:
->
I also added the ability to configure the zone programmatically with a public
.setZone(zone: string)The DateTimeOptions was passed to every method. I refactored it a bit so the methods that are only accepting the LocaleOptions only receive the LocaleOptions, and pass only the DateTimeOptions where the luxon methods are accepting it. This makes it clearer which methods are working with the zone and which are not. So I created a
_getLocaleOptionsand a_getDateTimeOptionsinstead of the current_getOptions. I hope you don't mind, it seems clearer to me this way.While writing the tests, I copied the UTC tests and tried to make it work with the new zone setting. One of my tests was failing and it turned out that the original test was not working correctly. I fixed that too ("should parse dates to UTC"). The date format was wrong and the parse gave back null and the test basically tested if null equals null.
I also added some remarks to the documentation where it talked about the useUTC parameter.