Disponible
amalgame-datetime
Instant ns-UTC, Duration, Stopwatch, ISO 8601.
Vue d'ensemble
Tout est en UTC, à la nanoseconde. Instant pour les dates, Duration pour les écarts, Stopwatch pour mesurer un temps sur l'horloge monotone. Lecture et écriture ISO 8601 et date HTTP (RFC 1123). L'heure locale et les fuseaux horaires ne sont pas encore là : ils sont prévus.
Caractéristiques
- ✓
Instant.Now(),Instant.Parse(s),Format(),Add,Since,IsBefore,IsAfter - ✓
Durationen nanosecondes :FromMillis,FromSeconds,FromMinutes,FromHours,FromDays - ✓
Stopwatchmonotonique pour timings non affectés par NTP - ✓Pause :
DateTime.SleepMillis(ms),Duration.Sleep(); dates HTTP :FormatHttpDate,ParseHttpDate - ✓Écrit en Amalgame, sauf la lecture des horloges
Exemple
Exemple minimal d'utilisation — recopiable tel quel après l'install.
amc package add datetime
import Amalgame.DateTime
class Program {
public static void Main() {
let sw = new Stopwatch()
DateTime.SleepMillis(120)
let took: Duration = sw.Elapsed()
Console.WriteLine("took " + String_FromInt(took.Millis()) + " ms")
let r: InstantResult = Instant.Parse("2026-05-24T10:30:00Z")
if (r.Ok) {
let later: Instant = r.Value.Add(Duration.FromHours(2))
Console.WriteLine(later.Format()) // 2026-05-24T12:30:00.000000000Z
Console.WriteLine(later.Since(r.Value).Format()) // 2h0m0s
}
}
}
En bref
- Licence : Apache-2.0
- Installation :
amc package add datetime - Code source : amalgame-lang/amalgame-datetime
- Index officiel : amalgame-lang/packages-index