7 Commits

Author SHA1 Message Date
Tina Liu
47c62e35c8
[Gregorian Calendar] Handle adding date components across DST transition like Calendar_ICU (#352)
Currently we implement adding units larger than `.day` as follows:
- Convert the date to date components
- Update the value of the added component
- Convert the date components back to date

The time of the day information is reduced to a `DateComponents` with, e.g. `hour == 1`, `minute == 30`, at step 1. Then when we convert the `DateComponents` back to `Date` at step 3, we always use the *first* occurrence of the time if it falls into the DST repeated time frame.

This is different from `Calendar_ICU`'s implementation, which uses the *latter* and rewind back the date by the DST transition interval (e.g. 1 hour for Pacific Time).

These yeild the same result except for when the input time and the output time are *both* during DST transition time frame. Update the implementation to match Calendar_ICU's behavior.
2023-12-22 10:11:34 +08:00
Tina Liu
a7020a3d07
[GregorianCalendar] Implement TimeZone support for date(from components: DateComponents) (#311)
* [GregorianCalendar] Implement TimeZone support for `date(from components: DateComponents)`

To support DST-observing time zone, add a helper function for TimeZone to return the raw offset and DST offset individually so we can fine tune the behavior for the time during the skipped time frame and the repeated time frame.

* remove an accidental import

* Add non-compatibility tests

* Review feedback: Remove mention of "GMT" in the date argument

* Review feedback: Change the returning type of DST offset from Int to TimeInterval to be consistent with the existing dstOffset API

* Implement the required function for _TimeZoneBridged

* Fix a missing import
2023-12-01 09:57:19 -08:00
Saleem Abdulrasool
28a5ce8c7e
FoundationEssentials: repair the TimeZone implementation on Windows
Update the Windows path for `String.range(of:)` being altered to
`String._range(of:anchored:backwards:)`. This repairs the build of
FoundationEssentials on Windows.
2023-11-27 09:39:39 -08:00
Roshan Kumar Sah
9a9e3c15bb
Documentation for Name Style in TimeZone (#176) 2023-11-07 15:04:17 -08:00
Charles Hu
7272a47c0b
Refactoring some import conditions (#298) 2023-10-25 15:11:37 -07:00
Tina Liu
62500a5d79
Follow up for #278 : make the required function from FoundationEssentials package so we can use it from FoundationI18n (#286)
* Follow up for #278 : make the required function from FoundationEssentials `package` so we can use it from FoundationI18n

* Workaround TAPI error by removing the default arguments
2023-10-06 16:03:57 -07:00
Tony Parker
d942713680
Sink TimeZone, Locale, Calendar to Essentials (#266)
* Sink Locale, Calendar to Essentials

* Add a Calendar test, make sure that _lock is populated early for NSSwiftCalendar
2023-09-25 16:09:16 -07:00