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
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 the current local datetime.
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
UtcNow
Returns the current datetime in UTC time as it is right now.
public static NsDateTime UtcNow { get; }
Property Value
Year
Property for the year of the DateTime
public int Year { get; set; }
Property Value
Methods
AddDays(double)
Adds a certain amount of days to the DateTime
public NsDateTime AddDays(double days)
Parameters
days
doubleThe 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
doubleThe 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
doubleThe 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
doubleThe 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
intThe 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
doubleThe 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
intThe 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
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
NsDateTimeThe current time
past
NsDateTimeThe 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
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