Table of Contents

Class DayUtil

Namespace
DxFeed.Graal.Net.Utils
Assembly
DxFeed.Graal.Net.dll

A collection of static utility methods for manipulation of int day id, that is the number of days since Unix epoch of January 1, 1970.
Ports the Java class com.devexperts.util.DayUtil.

public static class DayUtil
Inheritance
DayUtil
Inherited Members

Methods

GetDayIdByYearMonthDay(int)

Gets the day identifier for specified yyyymmdd integer in Gregorian calendar. The day identifier is defined as the number of days since Unix epoch of January 1, 1970. The yyyymmdd integer is equal to yearSign * (abs(year) * 10000 + month * 100 + day), where year, month, and day are in Gregorian calendar, month is between 1 and 12 inclusive, and day is counted from 1.

public static int GetDayIdByYearMonthDay(int yyyymmdd)

Parameters

yyyymmdd int

The yyyymmdd integer in Gregorian calendar.

Returns

int

The day id.

Examples

DayUtil.GetDayIdByYearMonthDay(19691231) == -1
DayUtil.GetDayIdByYearMonthDay(19700101) ==  0
DayUtil.GetDayIdByYearMonthDay(19700102) ==  1

Exceptions

ArgumentException

If the month is less than 1 or greater than 12.

See Also

GetDayIdByYearMonthDay(int, int, int)

Gets the day identifier for specified year, month and day in Gregorian calendar. The day identifier is defined as the number of days since Unix epoch of January 1, 1970. Month must be between 1 and 12 inclusive. Year and day might take arbitrary values assuming proleptic Gregorian calendar. The value returned by this method for an arbitrary day value always satisfies the following equality:

GetDayIdByYearMonthDay(year, month, day) == GetDayIdByYearMonthDay(year, month, 0) + day
public static int GetDayIdByYearMonthDay(int year, int month, int day)

Parameters

year int

The year.

month int

The month between 1 and 12 inclusive.

day int

The day.

Returns

int

The day id.

Exceptions

ArgumentException

If the month is less than 1 or greater than 12.

GetYearMonthDayByDayId(int)

Gets the integer yyyymmdd in Gregorian calendar for a specified day identifier. The day identifier is defined as the number of days since Unix epoch of January 1, 1970. The result is equal to:

yearSign * (abs(year) * 10000 + month * 100 + day)

where year, month, and day are in Gregorian calendar, month is between 1 and 12 inclusive, and day is counted from 1.

public static int GetYearMonthDayByDayId(int dayId)

Parameters

dayId int

A number of whole days since Unix epoch of January 1, 1970.

Returns

int

The yyyymmdd integer in Gregorian calendar.

Examples

DayUtil.GetYearMonthDayByDayId(-1) == 19691231
DayUtil.GetYearMonthDayByDayId(0)  == 19700101
DayUtil.GetYearMonthDayByDayId(1)  == 19700102