Repository F# setup
open System
open System.IO
open System.Threading
open System.Threading.Tasks
open Axial
open Axial.Console
open Axial.FileSystem
open Axial.Hosting
open Axial.Hosting.Browser
open Axial.Hosting.Node
open Axial.State
open Axial.Telemetry
open Axial.Telemetry.JavaScript
open Axial.Configuration
open Reified
open Reified.SchemaDSLCulture and time zones
Culture and TimeZone are explicit values. Read the machine defaults through a flow when a value should be
recorded in the environment or test platform:
open Axial
let localZone () : Flow<'env, 'error, Axial.TimeZone> = TimeZone.local
let localCulture () : Flow<'env, 'error, Culture> = Culture.system
AxiallocalZone: unit -> Flow<'env,'error,TimeZone>Axial.Flow`3enverrorAxial.TimeZoneA time zone selected explicitly as a value. Ids are IANA ids on every target; .NET also accepts Windows ids. UTC is always available.
Axial.TimeZoneModuleTime zone values and UTC-to-local conversion.
local: Flow<'env,'error,TimeZone>Reads the machine time zone as an explicit effect. Under Flow.runTest this is UTC, not the time zone of the test process.
localCulture: unit -> Flow<'env,'error,Culture>Axial.CultureA culture selected explicitly as a value. On .NET this wraps a read-only CultureInfo and implements IFormatProvider; on Fable it carries a BCP 47 name for Intl. The empty name is the invariant culture.
Axial.CultureModuleCulture values and explicit machine-default reads.
system: Flow<'env,'error,Culture>Reads the machine culture as an explicit effect. Under Flow.runTest this is the invariant culture, not the culture of the test process. Culture.system |> Flow.map (fun culture -> Format.date culture System.DateTimeOffset.UnixEpoch)
Requires & types
Requires: open Axial (packages: Axial)val localZone: unit -> Flow<'env,'error,TimeZone>val localCulture: unit -> Flow<'env,'error,Culture>TimeZone.local is an ambient machine read only inside the flow. It does not make System.TimeZoneInfo.Local part
of a pure function.
Convert to and from System.TimeZoneInfo
On .NET, an Axial.TimeZone preserves the actual System.TimeZoneInfo it was created from. That keeps custom
adjustment rules that are not available by id in the operating-system database:
open System
open Axial
let custom =
TimeZoneInfo.CreateCustomTimeZone(
"Application/Shift",
TimeSpan.FromHours -5.0,
"Application shift",
"Application standard",
"Application daylight",
[| TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule(
DateTime(2020, 1, 1),
DateTime(2030, 12, 31),
TimeSpan.FromHours 1.0,
TimeZoneInfo.TransitionTime.CreateFloatingDateRule(DateTime(1, 1, 1, 2, 0, 0), 3, 2, DayOfWeek.Sunday),
TimeZoneInfo.TransitionTime.CreateFloatingDateRule(DateTime(1, 1, 1, 2, 0, 0), 11, 1, DayOfWeek.Sunday)) |]
)
let zone = Axial.TimeZone.ofTimeZoneInfo custom
let preserved = Axial.TimeZone.toTimeZoneInfo zone
let wallClock = Axial.TimeZone.toLocal zone (DateTimeOffset(2024, 7, 1, 12, 0, 0, TimeSpan.Zero))
SystemAxialcustom: TimeZoneInfoSystem.TimeZoneInfoRepresents any time zone in the world.
CreateCustomTimeZone: string * TimeSpan * string * string * string * TimeZoneInfo.AdjustmentRule array -> TimeZoneInfoCreates a custom time zone with a specified identifier, an offset from Coordinated Universal Time (UTC), a display name, a standard time name, a daylight saving time name, and daylight saving time rules. The time zone's identifier. An object that represents the time difference between this time zone and Coordinated Universal Time (UTC). The display name of the new time zone. The new time zone's standard time name. The daylight saving time name of the new time zone. An array that augments the base UTC offset for a particular period. A object that represents the new time zone. The parameter is . The parameter is an empty string (""). -or- The parameter does not represent a whole number of minutes. The parameter is greater than 14 hours or less than -14 hours. The adjustment rules specified in the parameter overlap. -or- The adjustment rules specified in the parameter are not in chronological order. -or- One or more elements in are . -or- A date can have multiple adjustment rules applied to it. -or- The sum of the parameter and the value of one or more objects in the array is greater than 14 hours or less than -14 hours.
System.TimeSpanRepresents a time interval.
FromHours: float -> TimeSpanReturns a that represents a specified number of hours, where the specification is accurate to the nearest millisecond. A number of hours accurate to the nearest millisecond. An object that represents . is less than or greater than . -or- is . -or- is . is equal to .
CreateAdjustmentRule: DateTime * DateTime * TimeSpan * TimeZoneInfo.TransitionTime * TimeZoneInfo.TransitionTime -> TimeZoneInfo.AdjustmentRuleCreates a new adjustment rule for a particular time zone. The effective date of the adjustment rule. If the value of the parameter is , this is the first adjustment rule in effect for a time zone. The last date that the adjustment rule is in force. If the value of the parameter is , the adjustment rule has no end date. The time change that results from the adjustment. This value is added to the time zone's property to obtain the correct daylight offset from Coordinated Universal Time (UTC). This value can range from -14 to 14. An object that defines the start of daylight saving time. An object that defines the end of daylight saving time. An object that represents the new adjustment rule. The property of the or parameter does not equal . -or- The parameter is equal to the parameter. -or- The or parameter includes a time of day value. is earlier than . -or- is less than -14 or greater than 14. -or- The property of the parameter is not equal to 0. -or- The property of the parameter does not equal a whole number of seconds.
System.TimeZoneInfo.AdjustmentRuleProvides information about a time zone adjustment, such as the transition to and from daylight saving time.
``.ctor``: int * int * int -> unitInitializes a new instance of the structure to the specified year, month, and day. The year (1 through 9999). The month (1 through 12). The day (1 through the number of days in ). is less than 1 or greater than 9999. -or- is less than 1 or greater than 12. -or- is less than 1 or greater than the number of days in .
CreateFloatingDateRule: DateTime * int * int * DayOfWeek -> TimeZoneInfo.TransitionTimeDefines a time change that uses a floating-date rule (that is, a time change that occurs on a specific day of a specific week of a specific month). The time at which the time change occurs. This parameter corresponds to the property. The month in which the time change occurs. This parameter corresponds to the property. The week of the month in which the time change occurs. Its value can range from 1 to 5, with 5 representing the last week of the month. This parameter corresponds to the property. The day of the week on which the time change occurs. This parameter corresponds to the property. Data about the time change. The parameter has a non-default date component. -or- The parameter does not represent a whole number of milliseconds. -or- The parameter's property is not . is less than 1 or greater than 12. -or- is less than 1 or greater than 5. -or- The parameter is not a member of the enumeration.
System.TimeZoneInfo.TransitionTimeProvides information about a specific time change, such as the change from daylight saving time to standard time or vice versa, in a particular time zone.
``.ctor``: int * int * int * int * int * int -> unitInitializes a new instance of the structure to the specified year, month, day, hour, minute, and second. The year (1 through 9999). The month (1 through 12). The day (1 through the number of days in ). The hours (0 through 23). The minutes (0 through 59). The seconds (0 through 59). is less than 1 or greater than 9999. -or- is less than 1 or greater than 12. -or- is less than 1 or greater than the number of days in . -or- is less than 0 or greater than 23. -or- is less than 0 or greater than 59. -or- is less than 0 or greater than 59.
System.DayOfWeekSpecifies the day of the week.
Sunday: DayOfWeekIndicates Sunday.
zone: TimeZoneofTimeZoneInfo: TimeZoneInfo -> TimeZoneWraps a caller-supplied System.TimeZoneInfo, preserving custom adjustment rules. The conversion is not an ambient local-zone read. A null argument is an invalid host argument.
Axial.TimeZoneModuleTime zone values and UTC-to-local conversion.
preserved: TimeZoneInfotoTimeZoneInfo: TimeZone -> TimeZoneInfoReturns the preserved System.TimeZoneInfo, including any custom rules.
wallClock: DateTimeOffsettoLocal: TimeZone -> DateTimeOffset -> DateTimeOffsetConverts a UTC instant to the zone's wall clock. The result keeps the same instant with the zone's offset. Local-to-UTC conversion is not provided because skipped and repeated hours need a typed result. TimeZone.local |> Flow.map (fun zone -> TimeZone.toLocal zone System.DateTimeOffset.UnixEpoch)
``.ctor``: int * int * int * int * int * int * TimeSpan -> unitInitializes a new instance of the structure using the specified year, month, day, hour, minute, second, and offset. The year (1 through 9999). The month (1 through 12). The day (1 through the number of days in ). The hours (0 through 23). The minutes (0 through 59). The seconds (0 through 59). The time's offset from Coordinated Universal Time (UTC). does not represent whole minutes. is less than one or greater than 9999. -or- is less than one or greater than 12. -or- is less than one or greater than the number of days in . -or- is less than zero or greater than 23. -or- is less than 0 or greater than 59. -or- is less than 0 or greater than 59. -or- is less than -14 hours or greater than 14 hours. -or- The property is earlier than or later than .
Zero: TimeSpanRepresents the zero value. This field is read-only.
Requires & types
Requires: open System (packages: Axial)val custom: TimeZoneInfoval zone: TimeZoneval preserved: TimeZoneInfoval wallClock: DateTimeOffsetofTimeZoneInfo rejects a null argument with ArgumentNullException. toTimeZoneInfo returns the preserved object;
it does not look the id up again. Neither function reads the machine-local zone. Caller-supplied custom zones therefore
keep their rules even when the id is absent from the OS database.
On Fable, Axial.TimeZone carries only the id and these .NET-only conversions are not exported. Use
TimeZone.ofId and TimeZone.toLocal.

