Time

class · namespace z3n7 · source Essentials/Time.cs

public class Time

Time helpers: timestamps, deadlines, random pauses.

Methods

Cd

public static string Cd(object input = null, string o = "iso")

source

Returns a point in time counted from now (UTC), for cooldowns stored in the database.

Parameter Description
input null — today 23:59:59; "nextH" — one minute past the next hour; int/decimal — that many minutes from now (0 means practically never); other text — a TimeSpan such as "02:30:00" added to now.
o iso (yyyy-MM-ddTHH:mm:ss.fffZ) or unix (seconds). Anything else throws.

Elapsed

public static long Elapsed(long startTime = 0, bool useMs = false)

source

Time since startTime, or the current Unix time when startTime is 0.

Parameter Description
startTime Start as Unix time in the same unit as useMs selects.
useMs Milliseconds instead of seconds.

Now

public static string Now(string format = "unix")

source

Current UTC time as text.

Parameter Description
format unix — milliseconds since epoch; iso — yyyy-MM-ddTHH:mm:ss.fffZ; short — MM-ddTHH:mm; utcToId — seconds since epoch. Anything else throws.

TillNextHour

public static int TillNextHour()

source

Seconds left until the next full hour, local time.