Table of Contents

Class NsDateTime

Namespace
NominalSystems.Maths
Assembly
NominalSystems.Maths.dll

Class wrapper of a DateTime to be used by Mono

public class NsDateTime
Inheritance
NsDateTime

Constructors

NsDateTime()

Default constructor for the datetime Sets the datetime to the current time

public NsDateTime()

NsDateTime(DateTime)

Constructor that replaces the current reference with the datetime struct

public NsDateTime(DateTime dateTime)

Parameters

dateTime DateTime

The DateTime to copy

NsDateTime(int, int, int)

Constructor with a date

public NsDateTime(int year, int month, int day)

Parameters

year int

The year

month int

The month

day int

The day

NsDateTime(int, int, int, int, int, int)

Constructor with a date and time

public NsDateTime(int year, int month, int day, int hour, int minute, int second)

Parameters

year int

The year

month int

The month

day int

The day

hour int

The hours

minute int

The minutes

second int

The seconds

NsDateTime(int, int, int, int, int, int, int)

Constructor with a date and time (with milliseconds)

public NsDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond)

Parameters

year int

The year

month int

The month

day int

The day

hour int

The hours

minute int

The minutes

second int

The seconds

millisecond int

The milliseconds

NsDateTime(string)

Constructor that replaces the current reference with a string. For example: 2021 MAY 04 07:47:48.965 (UTC)

public NsDateTime(string dateTime)

Parameters

dateTime string

The DateTime as a string

NsDateTime(ulong)

Constructor with a nanoseconds since UNIX time and is able to convert from this time.

public NsDateTime(ulong nanos)

Parameters

nanos ulong

The number of nanos since Unix time

Properties

Date

Outputted date in a to string format from the DateTime

public string Date { get; }

Property Value

string

Day

Property for the day of the DateTime

public int Day { get; set; }

Property Value

int

Hour

Property for the hour of the DateTime

public int Hour { get; set; }

Property Value

int

Millisecond

Property for the millisecond of the DateTime

public int Millisecond { get; set; }

Property Value

int

Minute

Property for the minute of the DateTime

public int Minute { get; set; }

Property Value

int

Month

Property for the month of the DateTime

public int Month { get; set; }

Property Value

int

Now

Returns the current datetime in UTC

public static NsDateTime Now { get; }

Property Value

NsDateTime

Second

Property for the second of the DateTime

public int Second { get; set; }

Property Value

int

UnixSeconds

Returns the total number of seconds since the UNIX datetime

public double UnixSeconds { get; }

Property Value

double

Year

Property for the year of the DateTime

public int Year { get; set; }

Property Value

int

Methods

Equals(object)

Returns whether the two date times are identical or not

public override bool Equals(object obj)

Parameters

obj object

The other Universe

Returns

bool

Whether the two dates are equal

GetDateTime()

Returns the DateTime value if it exists

public DateTime GetDateTime()

Returns

DateTime

The DateTime struct

GetHashCode()

public override int GetHashCode()

Returns

int

Parse(string)

Parses a datetime as a string and returns the new date time

public static NsDateTime Parse(string date)

Parameters

date string

The string date

Returns

NsDateTime

The correct datetime

Set(int, int, int, int, int, int, int)

Sets the datetime to a new date

public void Set(int year, int month, int day, int hour, int minute, int second, int millisecond)

Parameters

year int

The year

month int

The month

day int

The day

hour int

The hours

minute int

The minutes

second int

The seconds

millisecond int

The milliseconds

ToString()

Converts the DateTime to a string

public override string ToString()

Returns

string

The formatted string

ToString(string)

Converts the DateTime to a string with some format

public string ToString(string format)

Parameters

format string

The format of the string

Returns

string

The converted string

UnixToDateTimeString(ulong)

Returns the datetime string from some UNIX nanoseconds that are passed in.

public static string UnixToDateTimeString(ulong unixNanos)

Parameters

unixNanos ulong

[ns] The number of nanoseconds since UNIX time

Returns

string

The formatted datetime string

Operators

operator +(NsDateTime, double)

Determines a new datetime that has a number of seconds added to it

public static NsDateTime operator +(NsDateTime date, double seconds)

Parameters

date NsDateTime

The datetime to start

seconds double

The seconds difference

Returns

NsDateTime

The new datetime with the difference in time

operator +(NsDateTime, TimeSpan)

Determines a new datetime that has a timespan added to it.

public static NsDateTime operator +(NsDateTime date, TimeSpan time)

Parameters

date NsDateTime

The datetime to start

time TimeSpan

The timespan difference

Returns

NsDateTime

The new datetime with the difference in time

operator -(NsDateTime, NsDateTime)

Returns the time span between the two NsDateTime values

public static TimeSpan operator -(NsDateTime current, NsDateTime past)

Parameters

current NsDateTime
past NsDateTime

Returns

TimeSpan

operator -(NsDateTime, double)

Determines a new datetime that has a number of seconds subtracted from it

public static NsDateTime operator -(NsDateTime date, double seconds)

Parameters

date NsDateTime

The datetime to start

seconds double

The seconds difference

Returns

NsDateTime

The new datetime with the difference in time

operator -(NsDateTime, TimeSpan)

Determines a new datetime that has a timespan subtracted from it.

public static NsDateTime operator -(NsDateTime date, TimeSpan time)

Parameters

date NsDateTime

The datetime to start

time TimeSpan

The timespan difference

Returns

NsDateTime

The new datetime with the difference in time