FIND YOUR NEXT FEW LINES

Results for “date arithmetic”

Small, practical examples. Search by task or narrow things down below.

292 snippets foundClear filters
SQLiteJSON data

Check whether text is valid JSON

Reject malformed input before processing it.

json_valid✓ Tested
C#Dates & precise numbers

Clamp a number to inclusive bounds

C#: Math.Clamp returns the nearest endpoint when the value lies outside the range.

C#✓ Tested
PowerShellDates & numeric validation

Clamp a number to inclusive bounds

PowerShell: Math.Clamp chooses the nearest endpoint for an out-of-range value.

PowerShell✓ Tested
Bash ScriptsText parsing & arithmetic

Clamp a numeric setting to a valid range

Bash Scripts: Use arithmetic comparisons before applying a user-supplied bounded setting.

Bash Scripts✓ Tested
CNumeric parsing & arithmetic

Clamp an integer to inclusive bounds

C: Explicit comparisons avoid relying on nonstandard min or max macros.

C✓ Tested
CNumeric parsing & arithmetic

Compare small floating-point results with a tolerance

C: Use an absolute difference threshold for this known bounded magnitude.

C✓ Tested
CNumeric parsing & arithmetic

Compute a two-dimensional vector length

C: hypot avoids unnecessary intermediate overflow compared with squaring both inputs directly.

C✓ Tested
PowerShellDates & numeric validation

Compute beyond the fixed-width integer range

PowerShell: BigInteger keeps an exact result when ordinary integer types are too small.

PowerShell✓ Tested
PythonDates & time zones

Convert a duration to hours and minutes

Python: Use divmod to split nonnegative whole seconds into display components.

Python✓ Tested
C#Dates & precise numbers

Convert a timestamp to a different fixed offset

C#: ToOffset changes the displayed local time while retaining the same instant.

C#✓ Tested
PythonDates & time zones

Convert a Unix timestamp to aware UTC

Python: Supply timezone.utc so the result does not depend on the machine time zone.

Python✓ Tested
Linux CommandsDates & process utilities

Convert a Unix timestamp to UTC

Linux Commands: Use the @ syntax with GNU date for seconds since the Unix epoch.

Linux Commands✓ Tested