Timestamp

Description

struct Tinman.Core.Util.Timestamp

A timestamp with millisecond precision, expressed in the Unix epoch and as a date in the Gregorian calendar in the UTC timezone.

Public / Constants

Epoch


public static readonly attribute Epoch → (Timestamp)

The Timestamp value of the Unix epoch:
1970-01-01 00:00:00.000

Future


public static readonly attribute Future → (Timestamp)

The most distant Timestamp in the future:
922337-12-31 23:59:59.999

So if you had a time machine, you could visit the Eloi and chat with some Morlocks on the 12th of October in the year 802701, but not much farther than that.

Invalid


public static readonly attribute Invalid → (Timestamp)

The special value for invalid timestamps.

Maximum


public static readonly attribute Maximum → (Timestamp)

The maximum sensible Timestamp value:
9999-12-31 23:59:59.999

Ticks​Per​Day


public constant TicksPerDay → (24 * 60 * 60 * 1000:int64)

The number of timestamp ticks per day (24 hours).

See also

Timestamp.Ticks

Ticks​Per​Hour


public constant TicksPerHour → (60 * 60 * 1000:int64)

The number of timestamp ticks per hour (60 minutes).

See also

Timestamp.Ticks

Ticks​Per​Millisecond


public constant TicksPerMillisecond → (1:int64)

The number of timestamp ticks per millisecond.

See also

Timestamp.Ticks

Ticks​Per​Minute


public constant TicksPerMinute → (60 * 1000:int64)

The number of timestamp ticks per minute (60 seconds).

See also

Timestamp.Ticks

Ticks​Per​Second


public constant TicksPerSecond → (1000:int64)

The number of timestamp ticks per second (1000 milliseconds).

See also

Timestamp.Ticks

Ticks​Per​Week


public constant TicksPerWeek → (7 * 24 * 60 * 60 * 1000:int64)

The number of timestamp ticks per calendar week (7 days).

See also

Timestamp.Ticks

Zero


public static readonly attribute Zero → (Timestamp)

The smallest sensible Timestamp value:
0000-01-01 00:00:00.000

Public / Constructors

From


[Pure]
public static method From → (7)

year in : int32

The year number. Will be clamped to [0..922337].

month in : int32

The month number. Will be clamped to [1..12].

day in : int64

The day number in the range [1..31]. Will wrap to adjacent months.

hour opt : int64 = 0

The hour number in the range [0..23]. Will wrap to adjacent days.

minute opt : int64 = 0

The minute number in the range [0..59]. Will wrap to adjacent hours.

second opt : int64 = 0

The second number in the range [0..59]. Will wrap to adjacent minutes.

millisecond opt : int64 = 0

The millisecond number in the range [0..999]. Will wrap to adjacent seconds.

returns → Timestamp

The Timestamp value.

Creates a new instance of Timestamp.

From​Sexagesimal


[Pure]
public static method FromSexagesimal → (1)

sexagesimal in : int64

See Sexagesimal.

returns → Timestamp

The Timestamp value.

Creates a new instance of Timestamp.

From​String


public static method FromString → (1)

value in : string

The string representation.

returns → Timestamp

The Timestamp value or Invalid iff value in is malformed.

Creates a new instance of Timestamp from its string representation, as returned by ToString2.

From​Ticks


[Pure]
public static method FromTicks → (1)

ticks in : int64

See Ticks.

returns → Timestamp

The Timestamp value.

Creates a new instance of Timestamp relative to Epoch.

Time


[Pure]
public static method Time → (4)

hour in : int32

The hour number. Will be clamped to [0..23].

minute in : int32

The minute number in the range [0..59]. Will wrap to adjacent hours.

second opt : int32 = 0

The second number in the range [0..59]. Will wrap to adjacent minutes.

millisecond opt : int32 = 0

The millisecond number in the range [0..999]. Will wrap to adjacent seconds.

returns → Timestamp

The Timestamp value.

Creates a new instance of Timestamp.

Public / Methods

Add


public method Add → (1)

ticks in : int64

The ticks to add, see Ticks.

returns → Timestamp

The resulting Timestamp value.

Adds the given ticks to this timestamp.

Sub


[Pure]
public method Sub → (1)

other in : Timestamp

The other timestamp.

returns → int64

The ticks of this timestamp minus the ticks of other in.

Returns the tick difference from this timestamp to the given one.

See also

Timestamp.Add

To​Date


[Pure]
public method ToDate → (3)

year in : int32

See Year.

month in : int32

See Month.

day in : int32

See Day.

returns → Timestamp

The resulting Timestamp value.

Sets Year, Month and Day to the given values, by delegating to From.

See also

Timestamp.ToTime

To​String

2 overloads


[Pure]
public method ToString2 → (1)

format in : int32

The format to use:
-3 : HH:MM:SS.FFF "23:59:59.999"
-2 : HH:MM:SS "23:59:59"
-1 : HH:MM "23:59"
=0 : choose automatically, based on zero components
+1 : YYYY-MM-DD "2000-12-31"
+2 : YYYY-MM-DD HH:MM "2000-12-31 23:59"
+3 : YYYY-MM-DD HH:MM:SS "2000-12-31 23:59:59"
+4 : YYYY-MM-DD HH:MM:SS.FFF "2000-12-31 23:59:59.999"

returns → string

The string representation. Will be empty iff IsInvalid is true.

Returns the string representation of this timestamp.

To​Time


[Pure]
public method ToTime → ()

returns → Timestamp

The resulting Timestamp value.

Sets Year, Month and Day to minimum values, by delegating to From.

See also

Timestamp.ToDate

Public / Attributes

Day


public attribute Day → (get)

value : int32

[1..31]
The day number.

Returns the day number.

Hour


public attribute Hour → (get)

value : int32

[0..23]
The hour number.

Returns the hour number.

Is​Invalid


public attribute IsInvalid → (get)

value : bool

true if invalid, false it not.

Is this the invalid timestamp value?

Millisecond


public attribute Millisecond → (get)

value : int32

[0..999]
The millisecond number.

Returns the millisecond number.

Minute


public attribute Minute → (get)

value : int32

[0..59]
The minute number.

Returns the minute number.

Month


public attribute Month → (get)

value : int32

[1..12]
The month number.

Returns the month number.

Now


public static attribute Now → (get)

value : Timestamp

The current date and time.

Second


public attribute Second → (get)

value : int32

[0..59]
The second number.

Returns the second number.

Sexagesimal


public readonly attribute Sexagesimal → (int64)

The date and time in the Gregorian calendar in the UTC timezone, in sexagesimal notation:

YYYYMMDDHHIISSFFF
|   | | | | | \__ millisecond [0..999]
|   | | | | \____ second      [0.. 59]
|   | | | \______ minute      [0.. 59]
|   | | \________ hour        [0.. 23]
|   | \_ day         [1..  31]
|   \___ month       [1..  12]
\_______ year number [0..9999]

For example:
   2000-12-31 23:59:59.999
=> 2000 01 31 23 59 59 999
=>       20000131235959999

Ticks


public readonly attribute Ticks → (int64)

The number of milliseconds since Epoch.

Weekday


public attribute Weekday → (get)

value : int32

[0..6]
The weekday number:
0 : Sunday,
1 : Monday
2 : Tuesday
3 : Wednesday
4 : Thursday
5 : Friday
6 : Saturday

Returns the weekday number.

Year


public attribute Year → (get)

value : int32

[0..922337]
The year number.

Returns the year number.

Serialization

Serializer


public static readonly attribute Serializer → (ITypeSerializerEx<Timestamp>)

The serialization helper object for values of Timestamp.