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
DateTimeThe DateTime to copy
NsDateTime(int, int, int)
Constructor with a date
public NsDateTime(int year, int month, int day)
Parameters
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
intThe year
month
intThe month
day
intThe day
hour
intThe hours
minute
intThe minutes
second
intThe 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
intThe year
month
intThe month
day
intThe day
hour
intThe hours
minute
intThe minutes
second
intThe seconds
millisecond
intThe 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
stringThe 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
ulongThe number of nanos since Unix time
Properties
Date
Outputted date in a to string format from the DateTime
public string Date { get; }
Property Value
Day
Property for the day of the DateTime
public int Day { get; set; }
Property Value
Hour
Property for the hour of the DateTime
public int Hour { get; set; }
Property Value
Millisecond
Property for the millisecond of the DateTime
public int Millisecond { get; set; }
Property Value
Minute
Property for the minute of the DateTime
public int Minute { get; set; }
Property Value
Month
Property for the month of the DateTime
public int Month { get; set; }
Property Value
Now
Returns the current datetime in UTC
public static NsDateTime Now { get; }
Property Value
Second
Property for the second of the DateTime
public int Second { get; set; }
Property Value
UnixSeconds
Returns the total number of seconds since the UNIX datetime
public double UnixSeconds { get; }
Property Value
Year
Property for the year of the DateTime
public int Year { get; set; }
Property Value
Methods
Equals(object)
Returns whether the two date times are identical or not
public override bool Equals(object obj)
Parameters
obj
objectThe 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
Parse(string)
Parses a datetime as a string and returns the new date time
public static NsDateTime Parse(string date)
Parameters
date
stringThe 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
intThe year
month
intThe month
day
intThe day
hour
intThe hours
minute
intThe minutes
second
intThe seconds
millisecond
intThe 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
stringThe 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
NsDateTimeThe datetime to start
seconds
doubleThe 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
NsDateTimeThe datetime to start
time
TimeSpanThe 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
NsDateTimepast
NsDateTime
Returns
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
NsDateTimeThe datetime to start
seconds
doubleThe 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
NsDateTimeThe datetime to start
time
TimeSpanThe timespan difference
Returns
- NsDateTime
The new datetime with the difference in time