LambdaFun.Time
1.2.1
dotnet add package LambdaFun.Time --version 1.2.1
NuGet\Install-Package LambdaFun.Time -Version 1.2.1
<PackageReference Include="LambdaFun.Time" Version="1.2.1" />
<PackageVersion Include="LambdaFun.Time" Version="1.2.1" />
<PackageReference Include="LambdaFun.Time" />
paket add LambdaFun.Time --version 1.2.1
#r "nuget: LambdaFun.Time, 1.2.1"
#:package LambdaFun.Time@1.2.1
#addin nuget:?package=LambdaFun.Time&version=1.2.1
#tool nuget:?package=LambdaFun.Time&version=1.2.1
LambdaFun.Time
High-precision time utilities for F#. A drop-in, ergonomic type for timestamping, measuring durations, sequencing time points, and doing precise arithmetic with wall-clock time. Built on top of .NET’s Stopwatch and DateTime to map high-resolution local ticks into UTC ticks, giving you high-precision “now” with familiar DateTime semantics.
- Target frameworks: .NET Framework 4.8.1, .NET Standard 2.0, .NET Core 3.1, .NET 8, .NET 9
- Language: F#, compatible with C# clients.
Why use Time?
- High-precision
Now: CombinesStopwatch.GetTimestamp()with UTC ticks for precise current time. - Safe arithmetic: Add/subtract
TimeSpanor milliseconds directly onTime. - Natural comparisons:
=,<>,<,<=,>,>=work as expected. - Interop friendly: Convert to
DateTime,TimeSpan, and raw ticks easily. - Sequences: Generate forward/backward time series, including infinite streams.
Install
NuGet Package Manager:
PM> Install-Package LambdaFun.Time
Paket CLI:
> dotnet paket add LambdaFun.Time --project _my_project_
Quick start
// F#
open System
open LambdaFun
let t0 = Time.Now
do something()
let t1 = Time.Now
let elapsed: TimeSpan = t1 - t0
printfn "Elapsed: %A ms" elapsed.TotalMilliseconds
// Arithmetic
let in500ms = t0 + 500
let in2_5ms = t0 + 2.5m
let in1s = t0 + TimeSpan.FromSeconds 1
// Comparison
if Time.Now >= in1s then printfn "At or past 1 second mark."
// Interop
let dt: DateTime = t0.DateTime
let ticks: int64 = t0.Ticks
API overview
Construction
Time.Now: high-precision current timeTime(year, month, day)Time(year, month, day, hour, minute, second)Time(dateTime: DateTime)Time.Default: zero-based sentinel time
Properties
Ticks: int64DateTime: DateTimeAge: TimeSpan(since creation, using high-precision Now)Year|Month|Day|Hour|Minute|Second
Operators
- time
+ TimeSpan -> Time - time
+ int (milliseconds) -> Time - time
+ decimal (milliseconds) -> Time - time
- TimeSpan -> Time - time1
-time2-> TimeSpan =,<>,<,<=,>,>=
- time
Sequences
Time.InfiniteSequence start step: seqTime.Sequence start finish step: seq(forward or backward)
Usage patterns
High-precision elapsed timing
- Capture
let t = Time.Nowbefore work, subtract later for TimeSpan.
- Capture
Scheduling/checkpoints
- Compute future instants with
Time + TimeSpanand compare.
- Compute future instants with
Time series generation
- Build sampling points using
Time.Sequence start finish (TimeSpan.FromMilliseconds 10.0).
- Build sampling points using
Sentinel/default values
- Use
Time.Defaultwhen an optional timestamp isn’t set.
- Use
Notes
- Timezone: Time.Now maps to UTC ticks; Time.DateTime is UTC unless you convert.
- Determinism: Precision relies on
Stopwatch.Frequencyand monotonic ticks at runtime. - Collections: Implements equality, hash code, and
IComparablefor maps/sets.
License
LGPL. See the project license for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 is compatible. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETCoreApp 3.1
- FSharp.Core (>= 9.0.303)
- System.ValueTuple (>= 4.6.1)
-
.NETFramework 4.8.1
- FSharp.Core (>= 9.0.303)
- System.ValueTuple (>= 4.6.1)
-
.NETStandard 2.0
- FSharp.Core (>= 9.0.303)
- System.ValueTuple (>= 4.6.1)
-
net8.0
- FSharp.Core (>= 9.0.303)
- System.ValueTuple (>= 4.6.1)
-
net9.0
- FSharp.Core (>= 9.0.303)
- System.ValueTuple (>= 4.6.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.