Results for “Dates & time zones”
Small, practical examples. Search by task or narrow things down below.
Clamp a number to inclusive bounds
C#: Math.Clamp returns the nearest endpoint when the value lies outside the range.
C#✓ Tested
Clamp a number to inclusive bounds
PowerShell: Math.Clamp chooses the nearest endpoint for an out-of-range value.
PowerShell✓ Tested
Compute beyond the fixed-width integer range
PowerShell: BigInteger keeps an exact result when ordinary integer types are too small.
PowerShell✓ Tested
Construct an instant relative to the Unix epoch
Construct an instant relative to the Unix epoch in a complete Rust program using the standard library.
Rust✓ Tested
Copy a file with explicit permissions
Linux Commands: Use install to create parent directories and set the destination mode in one operation.
Linux Commands✓ Tested
Detect integer overflow with checked
C#: A checked arithmetic block throws instead of silently wrapping an integer result.
C#✓ Tested
Find the length of a calendar month
C#: DaysInMonth applies the Gregorian leap-year rules.
C#✓ Tested
Find the number of days in a month
PowerShell: DaysInMonth handles leap-year February correctly.
PowerShell✓ Tested
Format a zero-padded numeric label
Linux Commands: Use printf formatting instead of concatenating a variable number of zeroes.
Linux Commands✓ Tested
Generate a stepped sequence
Linux Commands: Use seq when a command pipeline needs a numeric sequence.
Linux Commands✓ Tested
Give a date a machine-readable value
HTML: Learn how to give a date a machine-readable value in a complete browser example.
HTML✓ Tested
Handle incomplete serial input
Arduino / C: The returned byte count distinguishes a complete payload from a timed-out partial one.
Arduino / C✓ Tested