Table of Contents

Class NsDateTime

Namespace
NominalSystems.Maths
Assembly
NominalSystems.Maths.dll

Class wrapper that represents a DateTime within a class. This is useful for Mono and is able to convert between the standard C++ classes and the C# classes.

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 the current local datetime.

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

UtcNow

Returns the current datetime in UTC time as it is right now.

public static NsDateTime UtcNow { get; }

Property Value

NsDateTime

Year

Property for the year of the DateTime

public int Year { get; set; }

Property Value

int

Methods

AddDays(double)

Adds a certain amount of days to the DateTime

public NsDateTime AddDays(double days)

Parameters

days double

The number of days to add

Returns

NsDateTime

The DateTime that has the days added

AddHours(double)

Adds a certain amount of hours to the DateTime

public NsDateTime AddHours(double hours)

Parameters

hours double

The number of hours to add

Returns

NsDateTime

The DateTime that has the hours added

AddMilliseconds(double)

Adds a certain amount of milliseconds to the DateTime

public NsDateTime AddMilliseconds(double milliseconds)

Parameters

milliseconds double

The number of milliseconds to add

Returns

NsDateTime

The DateTime that has the milliseconds added

AddMinutes(double)

Adds a certain amount of minutes to the DateTime

public NsDateTime AddMinutes(double minutes)

Parameters

minutes double

The number of minutes to add

Returns

NsDateTime

The DateTime that has the minutes added

AddMonths(int)

Adds a certain amount of months to the DateTime

public NsDateTime AddMonths(int months)

Parameters

months int

The number of months to add

Returns

NsDateTime

The DateTime that has the months added

AddSeconds(double)

Adds a certain amount of seconds to the DateTime

public NsDateTime AddSeconds(double seconds)

Parameters

seconds double

The number of seconds to add

Returns

NsDateTime

The DateTime that has the seconds added

AddYears(int)

Adds a certain amount of years to the DateTime

public NsDateTime AddYears(int years)

Parameters

years int

The number of years to add

Returns

NsDateTime

The DateTime that has the years added

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

The current time

past NsDateTime

The past time

Returns

TimeSpan

The timespan between the two

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