Table of Contents

Class WorldClockText

Namespace
FishMMO.Database.Data
Assembly
FishMMO-DB.dll

The written forms of world time, shared by every surface that reads or writes the world clock (the Control Panel, and available to the in-game /admin time commands) so the two can never disagree about what a typed value means.

public static class WorldClockText
Inheritance
WorldClockText
Inherited Members

Remarks

A WORLD TIMESTAMP is the calendar epoch (Unix seconds) plus the world milliseconds, written yyyy-MM-dd HH:mm:ss.fff in the invariant culture with no zone: it is UTC-style arithmetic on a calendar, not anybody's local time.

A CHANGE is a signed span: +1h30m, -90s, +2d3h4m5.25s, +250ms. Units d, h, m, s, ms, each at most once, largest first; a bare signed number is seconds. The sign is required, which is what tells a change from a timestamp.

Fields

Format

The one output format.

public const string Format = "yyyy-MM-dd HH:mm:ss.fff"

Field Value

string

MaxCalendarUnixMs

The latest instant a timestamp can name: 9999-12-31 23:59:59.999, Unix ms.

public const long MaxCalendarUnixMs = 253402300799999

Field Value

long

MaxEpochUnixSeconds

The latest epoch representable: 9999-12-31 23:59:59, Unix seconds.

public const long MaxEpochUnixSeconds = 253402300799

Field Value

long

MinEpochUnixSeconds

The earliest epoch representable: 0001-01-01, Unix seconds.

public const long MinEpochUnixSeconds = -62135596800

Field Value

long

Methods

FormatChange(long)

Writes a span of milliseconds in the change syntax, largest unit first: +1h30m, -1d, +0s.

public static string FormatChange(long deltaMs)

Parameters

deltaMs long

Returns

string

FormatTimestamp(long, long)

Formats world milliseconds as a world timestamp, or returns null when the instant falls outside the years 1–9999 (an epoch or a world time that no calendar date can name).

public static string? FormatTimestamp(long epochUnixSeconds, long worldMs)

Parameters

epochUnixSeconds long
worldMs long

Returns

string

IsValidEpoch(long)

Whether an epoch can be written as a calendar date at all.

public static bool IsValidEpoch(long epochUnixSeconds)

Parameters

epochUnixSeconds long

Returns

bool

TryParseChange(string?, out long, out string?)

Parses a signed change such as +1h30m, -90s or +2d3h4m5.25s into milliseconds, rounded to the nearest millisecond.

public static bool TryParseChange(string? text, out long deltaMs, out string? error)

Parameters

text string

The change. The sign is required.

deltaMs long

The signed change in milliseconds.

error string

Why it was refused, written for the person who typed it.

Returns

bool

TryParseTimestamp(string?, long, out long, out string?)

Parses a world timestamp into world milliseconds since the epoch. Refuses an instant before the epoch (world time cannot be negative) and anything unparseable.

public static bool TryParseTimestamp(string? text, long epochUnixSeconds, out long worldMs, out string? error)

Parameters

text string

The timestamp, in one of the accepted formats.

epochUnixSeconds long

The calendar epoch, from the world clock row.

worldMs long

World milliseconds since the epoch.

error string

Why it was refused, written for the person who typed it.

Returns

bool

TryToInstant(long, long, out DateTimeOffset)

The instant a world time names, when one exists in years 1–9999.

public static bool TryToInstant(long epochUnixSeconds, long worldMs, out DateTimeOffset instant)

Parameters

epochUnixSeconds long
worldMs long
instant DateTimeOffset

Returns

bool