33 Commits

Author SHA1 Message Date
Tony Parker
63cfcb9bfd
ISO8601 DateComponents format style (#1209)
* ISO8601 DateComponents style

* Add Hashable to ISO8601FormatStyle
2025-04-04 13:58:57 -07:00
Johannes Weiss
601e847faa
always @preconcurrency import Glibc (#1175)
Co-authored-by: Johannes Weiss <johannes@jweiss.io>
2025-03-04 09:25:51 -08:00
Alex Lorenz
156ab327d9
[android] fix the tm_zone access, which is nullable on Android (#1056) 2024-11-21 13:51:47 -08:00
Marc Prud'hommeaux
0d7747ca4c
Detect current timezone on Android the same as Linux (#1053) 2024-11-20 10:08:24 -08:00
Yuta Saito
f77911a0e8
[wasm] Fix WASI build around TimeZone (#984)
https://github.com/swiftlang/swift-foundation/pull/975 started to
restrict the fallback value for `TZDIR` and it revealed that WASI
platform implicitly depends on TZDIR even though it won't have such
directory. This patch explicitly handles the case for WASI platform for
timezone operations.
2024-10-18 16:02:58 +09:00
Jeremy Schonfeld
889c38fdb9
Fix TimeZone.current lookup on Windows (#975) 2024-10-11 10:49:46 -07:00
finagolfin
53ffff0600
[Android] Enable more code and tests (#871)
* [Android] Enable more code and tests

while disabling setting extended file attributes and a test creating a hard link,
features not normally allowed on Android.

* Remove incorrect WASI check
2024-09-17 08:40:40 -07:00
Tony Parker
446af5c0c5
Formatting performance improvements (#884) 2024-08-23 14:13:17 -07:00
finagolfin
c15a5e1f5c
[Android] Use the Bionic module in more places (#842)
Also, use `canImport()` wherever importing APIs, reserving `os(Android)` for
platform differences.
2024-08-15 14:34:15 -07:00
Evan Wilde
aecc1b158c
[main] Get Swift-Foundation building against MUSL for Swift Static SDK (#848)
* Get FoundationEssentials building

Adding the missing musl imports to get FoundationEssentials building for
the Swift static SDKs again.

Also providing an option to disable building the macros. The macros
aren't necessary for building the library and will not be run as part of
the static SDK. No need to bloat the SDK or build times further. For
Swift 6, the macros should be provided by the toolchain since the
toolchain and SDK are current revlocked due to swiftmodules.

* Get FoundationInternationalization building

Adding the missing Musl imports to get FoundationInternationalization
building for the static SDK.
2024-08-14 13:34:15 -07:00
Jeremy Schonfeld
196376b5fd
Use dynamic replacement instead of _typeByName for internationalization upcalls (#756)
* Use dynamic replacement instead of _typeByName for internationalization upcalls

* Make FOUNDATION_FRAMEWORK function non-dynamic

* Fix build failures
2024-07-23 14:43:01 -07:00
Tony Parker
90109a4cf6
Revert formatting performance improvements (#744)
There appears to be some kind of race or memory smash in ICU after these, and we need more time to investigate the full root cause.
2024-07-18 17:43:34 -07:00
Tony Parker
6ee772ba7f
Improve performance of FormatStyle formatting when used in multithreaded context (#719)
* Improve performance of FormatStyle formatting when used in multithreaded context

* Change canImport statement to support newer SDK on older macOS
2024-07-09 10:06:47 -07:00
Saleem Abdulrasool
a7692238a8
FoundationEssentials: initial pass to add Android support (#704)
This adds the necessary guards and includes for the Android modules.
While the module does not compile currently due to nullability
differences (and in some cases missing declarations), this at least
brings the module to a point where we can start working on the errors
and differences to create a maintainable codebase for Android.
2024-06-26 16:00:37 -07:00
Charles Hu
60506f3af4
Renamed _CShims to _FoundationCShims (#656)
Rationale: _CShims will effectivly become semi-public in the toolchain. We add the Foundation prefix to make it less generic.
2024-06-21 16:18:38 -07:00
Charles Hu
8976fc4fd6
Introduce Cmake support for SwiftFoundation (#573) 2024-06-16 22:21:28 -07:00
Tony Parker
caa08cf226
Enable complete concurrency checking in Foundation 2024-06-04 10:41:59 -07:00
Charles Hu
6566925d60
Update remaining references of FoundationICU to _FoundationICU (#649) 2024-06-03 14:59:28 -07:00
Charles Hu
2a8e9438ec
Upgrade FoundationICU to 0.0.7 (#645) 2024-05-31 13:50:07 -07:00
Jeremy Schonfeld
bacec51eb5
Remove custom tz file reading code (#633) 2024-05-24 13:02:32 -07:00
Saleem Abdulrasool
7cfdf230ee
FoundationEssentials: tweak TimeZone handling for Windows (#576)
Use the Win32 APIs for environment access to ensure that we handle
unicode values properly, adjust the logic to deal with encoding
differences.
2024-05-01 17:21:53 -07:00
Saleem Abdulrasool
3e4077fcaf
FoundationEssentials: clean up some Windows warnings (#571)
Use the Windows POSIX API spellings to avoid the warnings. Take the
opportunity to change the environment handling to ensure that we are
able to handle weird unicode environment variables which may not be
rendered properly in the ASCII environment representation. Adjust some
types to better match the implementation on Windows which is a minor uop
to avoid unnecessary `trunc` and `sext` or `zext`.
2024-05-01 13:40:29 -07:00
Saleem Abdulrasool
b80fb683b6
FoundationEssentials: provide typed overloads for constants from WinSDK
This allows for us to use the constants without explicitly casting the
type to `DWORD` on each site of use. By providing the shadowing
overload we can simply use the constants without impacting the
readability of the surrounding code.
2024-04-11 15:53:31 -07:00
Jeremy Schonfeld
92d9e5210a
Fix build failures related to tz data file 2024-04-10 09:42:41 -07:00
Tony Parker
ec730c21f0
Build swift-corelibs-foundation as a package on top of swift-foundation (#514)
* Provide public access for some internal functions, to enable swift-corelibs-foundation

* Add access to TimeZone internals for swift-corelibs-foundation

* Fix default TimeZone for Linux

* Remove unneeded private entry point

* Do not use a recursive definition of description for String.Encoding

* Merge in some WASI changes and other Data fixes

* Add temporary initializer to the stub URL

* Remove Hashable conformance for CocoaError. This allows userInfo to be Any instead of AnyHashable

* Remove some protocols which depend on NSError from swift-foundation -- they will live in swift-corelibs-foundation

* Adjust the debug description of the GMT ICU calendar to be a little less implementation-specific

* Use an English-only description for string encodings, for compatibility with existing SCL-F clients

* Use a more compatible definition of a backstop value for Bundle
2024-03-28 14:55:31 -07:00
Jeremy Schonfeld
e5211f2926
(122981400) Standardize on using internal import 2024-03-06 13:42:02 -08:00
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