Table of Contents

Class DateTimeLibrary

Namespace
NominalSystems.Universe
Assembly
NominalSystems.Universe.dll

[Nominal] A datetime library will be used to provide a set of functions for working with dates and times.


public static class DateTimeLibrary
Inheritance
DateTimeLibrary

Methods

DateTimeToUnix(DateTime)

Calculates the UNIX time in seconds from a datetime. This will be the number of seconds since the start of 1970.

public static double DateTimeToUnix(DateTime time)

Parameters

time DateTime

The datetime to fetch

Returns

double

[s] The total seconds since UNIX time

GetDayOfYear(DateTime)

Returns the day of year index, where January 1st is 1, and December 31st is 365 (or 366 for leap years).

public static int GetDayOfYear(DateTime date)

Parameters

date DateTime

The date to check

Returns

int

The Day of Year (DoY)

GetDayOfYear(int, int, int)

Returns the day of year index, where January 1st is 1, and December 31st is 365 (or 366 for leap years).

public static int GetDayOfYear(int year, int month, int day)

Parameters

year int

The year of the date

month int

The month of the year

day int

The day of the month

Returns

int

GetDaysInYear(int)

Returns the number of days in the calendar year based on whether the year is a leap year or not.

public static int GetDaysInYear(int year)

Parameters

year int

The year to check

Returns

int

The number of days in the year

GetDecimalYear(DateTime)

Returns the year as a decimal place with the decimal being the fraction within the year. For example, half-way through the year on July 2nd of the year would be 0.5.

public static double GetDecimalYear(DateTime date)

Parameters

date DateTime

The datetime to convert

Returns

double

The decimal year

GetDecimalYear(int, int, int, int, int, double)

Returns the year as a decimal place with the decimal being the fraction within the year. For example, half-way through the year on July 2nd of the year would be 0.5.

public static double GetDecimalYear(int year, int month, int day, int hour, int minute, double seconds)

Parameters

year int

The year of the date

month int

The month of the year

day int

The day of the month

hour int

The hour in the day

minute int

The minute in the hour

seconds double

The seconds of the hour

Returns

double

The decimal year

GetSecondsOfDay(DateTime)

Returns the number of seconds in the day that has elapsed. This is the number of seconds since the start of the day, from 00:00:00.

public static double GetSecondsOfDay(DateTime date)

Parameters

date DateTime

The date to check

Returns

double

[s] The elapsed seconds since 00:00:00

GetSecondsOfDay(int, int, double)

Returns the number of seconds in the day that has elapsed. This is the number of seconds since the start of the day, from 00:00:00.

public static double GetSecondsOfDay(int hour, int minute, double seconds)

Parameters

hour int

The hour in the day

minute int

The minute in the hour

seconds double

The seconds in the minute

Returns

double

[s] The elapsed seconds since 00:00:00

IsLeapYear(int)

Determines if a year is a leap year and has 366 days in the year. This occurs every 4 years, but not every 100 years, unless it is every 400 years.

public static bool IsLeapYear(int year)

Parameters

year int

The year to check

Returns

bool

A flag whether the year is a leap year

UnixToDateTime(double)

Constructs a datetime from a UNIX timestamp in seconds. This will return the datetime since 1970.

public static DateTime UnixToDateTime(double seconds)

Parameters

seconds double

[s] The time since UNIX time

Returns

DateTime

The datetime from UNIX time with the difference

UnixToDateTimeNanos(long)

Constructs a datetime from a UNIX timestamp in nanoseconds. This will return the datetime since 1970.

public static DateTime UnixToDateTimeNanos(long nanos)

Parameters

nanos long

[ns] The time since UNIX time

Returns

DateTime

The datetime from UNIX time with the difference