LambdaFun.Time 1.2.1

dotnet add package LambdaFun.Time --version 1.2.1
                    
NuGet\Install-Package LambdaFun.Time -Version 1.2.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LambdaFun.Time" Version="1.2.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LambdaFun.Time" Version="1.2.1" />
                    
Directory.Packages.props
<PackageReference Include="LambdaFun.Time" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LambdaFun.Time --version 1.2.1
                    
#r "nuget: LambdaFun.Time, 1.2.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LambdaFun.Time@1.2.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LambdaFun.Time&version=1.2.1
                    
Install as a Cake Addin
#tool nuget:?package=LambdaFun.Time&version=1.2.1
                    
Install as a Cake Tool

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: Combines Stopwatch.GetTimestamp() with UTC ticks for precise current time.
  • Safe arithmetic: Add/subtract TimeSpan or milliseconds directly on Time.
  • 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 time
    • Time(year, month, day)
    • Time(year, month, day, hour, minute, second)
    • Time(dateTime: DateTime)
    • Time.Default: zero-based sentinel time
  • Properties

    • Ticks: int64
    • DateTime: DateTime
    • Age: 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
    • =, <>, <, <=, >, >=
  • Sequences

    • Time.InfiniteSequence start step: seq
    • Time.Sequence start finish step: seq(forward or backward)

Usage patterns

  • High-precision elapsed timing

    • Capture let t = Time.Now before work, subtract later for TimeSpan.
  • Scheduling/checkpoints

    • Compute future instants with Time + TimeSpan and compare.
  • Time series generation

    • Build sampling points using Time.Sequence start finish (TimeSpan.FromMilliseconds 10.0).
  • Sentinel/default values

    • Use Time.Default when an optional timestamp isn’t set.

Notes

  • Timezone: Time.Now maps to UTC ticks; Time.DateTime is UTC unless you convert.
  • Determinism: Precision relies on Stopwatch.Frequency and monotonic ticks at runtime.
  • Collections: Implements equality, hash code, and IComparable for maps/sets.

License

LGPL. See the project license for details.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.1 215 11/2/2025
1.1.0 1,214 10/28/2018
1.0.0 2,600 10/28/2014