FIND YOUR NEXT FEW LINES

Results for “Dates & times”

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

126 snippets foundClear filters
PythonDates & time zones

Advance a date by a number of days

Python: Use timedelta so month and year boundaries are handled automatically.

Python✓ Tested
Linux CommandsDates & process utilities

Bound a command execution time

Linux Commands: Use timeout and handle status 124 as an expected time limit.

Linux Commands✓ Tested
C#Dates & precise numbers

Calculate an integer beyond the 64-bit range

C#: Use BigInteger for arbitrary-precision integer arithmetic.

C#✓ Tested
JavaDates & time zones

Check the Gregorian leap-year rule

Java: Use Year.isLeap rather than checking divisibility by four alone.

Java✓ 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
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
PythonDates & time zones

Convert an aware datetime to another offset

Python: Use astimezone for conversion; replacing tzinfo alone does not convert an instant.

Python✓ Tested
JavaDates & time zones

Convert an instant to a regional timezone

Java: Use ZonedDateTime with a named zone to apply that zone’s offset rules.

Java✓ Tested
JavaDates & time zones

Convert epoch seconds into an instant

Java: Instant represents a UTC timeline point independent of the default timezone.

Java✓ Tested
Linux CommandsDates & process utilities

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