Table of Contents

Class DateTimeUtils

Namespace
Common
Assembly
Lykke.Common.dll
public static class DateTimeUtils
Inheritance
DateTimeUtils
Inherited Members

Fields

SecondsInDay

public const int SecondsInDay = 86400

Field Value

int

StandartDate

public const string StandartDate = "dd/MM/yyyy"

Field Value

string

StandartDateTimeMask

public const string StandartDateTimeMask = "dd.MM.yy HH:mm:ss"

Field Value

string

Methods

FromUnixDateTime(uint)

public static DateTime FromUnixDateTime(this uint unixDateTime)

Parameters

unixDateTime uint

Returns

DateTime

GenerateDates(DateTime, DateTime)

Сгенерировать даты (без времени)

public static IEnumerable<DateTime> GenerateDates(DateTime dateFrom, DateTime dateTo)

Parameters

dateFrom DateTime

дата с которой начать

dateTo DateTime

дата которой закончить (включительно)

Returns

IEnumerable<DateTime>

GenerateMonthDates(int, int)

Сгенерировать даты за определенный месяц

public static IEnumerable<DateTime> GenerateMonthDates(int year, int month)

Parameters

year int
month int

Returns

IEnumerable<DateTime>

GetFirstWeekOfYear(DateTime)

Returns date of the first weeks' monday in that year.

public static DateTime GetFirstWeekOfYear(DateTime dt)

Parameters

dt DateTime

Returns

DateTime

GetFirstWeekOfYear(int, DateTimeKind)

Returns date of the first week's monday in the specified year.

public static DateTime GetFirstWeekOfYear(int year, DateTimeKind kind = DateTimeKind.Utc)

Parameters

year int
kind DateTimeKind

Returns

DateTime

IsIsoDateTimeString(string)

public static bool IsIsoDateTimeString(string value)

Parameters

value string

Returns

bool

RoundSeconds(DateTime)

[Obsolete("Use RoundToMinute(DateTime). RoundToMinute - is not misprint, RoundSeconds rounds to the minute")]
public static DateTime RoundSeconds(DateTime dateTime)

Parameters

dateTime DateTime

Returns

DateTime

RoundToHour(DateTime)

Truncates DateTime to the hours

public static DateTime RoundToHour(this DateTime dateTime)

Parameters

dateTime DateTime

DateTime to truncate

Returns

DateTime

RoundToHour(DateTime, int)

Truncates DateTime to the hour hours

public static DateTime RoundToHour(this DateTime dateTime, int hour)

Parameters

dateTime DateTime

DateTime to truncate

hour int

5 - truncates to 5 hours

Returns

DateTime

RoundToMinute(DateTime)

Truncates DateTime to the minutes

public static DateTime RoundToMinute(this DateTime dateTime)

Parameters

dateTime DateTime

DateTime to truncate

Returns

DateTime

RoundToMinute(DateTime, int)

Truncates DateTime to the min minutes

public static DateTime RoundToMinute(this DateTime dateTime, int min)

Parameters

dateTime DateTime

DateTime to truncate

min int

5 - truncates to 5 minutes

Returns

DateTime

RoundToMinutes(DateTime, int)

[Obsolete("Use RoundToMinute(DateTime, int)")]
public static DateTime RoundToMinutes(DateTime dateTime, int minInterval)

Parameters

dateTime DateTime
minInterval int

Returns

DateTime

RoundToMonth(DateTime)

Уменьшаем точность до часа - отбрасывая минуты

public static DateTime RoundToMonth(this DateTime dateTime)

Parameters

dateTime DateTime

Исходное дата-время

Returns

DateTime

Округленная дата-время

RoundToSecond(DateTime)

Truncates DateTime to the seconds

public static DateTime RoundToSecond(this DateTime dateTime)

Parameters

dateTime DateTime

Returns

DateTime

RoundToSecond(DateTime, int)

Truncates DateTime to the sec seconds

public static DateTime RoundToSecond(this DateTime dateTime, int sec)

Parameters

dateTime DateTime

DateTime to truncate

sec int

5 - truncates to 5 seconds

Returns

DateTime

RoundToWeek(DateTime)

Decreases date precision down to week. Shifts date to monday

public static DateTime RoundToWeek(this DateTime dateTime)

Parameters

dateTime DateTime

Returns

DateTime

RoundToYear(DateTime)

Уменьшаем точность до года - отбрасывая все остальное

public static DateTime RoundToYear(this DateTime dateTime)

Parameters

dateTime DateTime

Исходное дата-время

Returns

DateTime

Округленная дата-время

SetTime(DateTime, int, int, int)

public static DateTime SetTime(this DateTime src, int hours, int mins, int seconds)

Parameters

src DateTime
hours int
mins int
seconds int

Returns

DateTime

ToDateString(DateTime?)

public static string ToDateString(this DateTime? value)

Parameters

value DateTime?

Returns

string

ToHtmlComponentDate(DateTime)

public static string ToHtmlComponentDate(this DateTime dateTime)

Parameters

dateTime DateTime

Returns

string

ToIsoDate(DateTime)

public static string ToIsoDate(this DateTime dateTime)

Parameters

dateTime DateTime

Returns

string

ToIsoDateTime(DateTime)

public static string ToIsoDateTime(this DateTime dateTime)

Parameters

dateTime DateTime

Returns

string

ToTimeString(DateTime, char)

public static string ToTimeString(this DateTime dateTime, char separator = ':')

Parameters

dateTime DateTime
separator char

Returns

string

ToUnixTime(DateTime)

public static double ToUnixTime(this DateTime dateTime)

Parameters

dateTime DateTime

Returns

double

ToYyyyMmDd(DateTime)

public static string ToYyyyMmDd(this DateTime dateTime)

Parameters

dateTime DateTime

Returns

string

TruncMiliseconds(DateTime)

[Obsolete("Use RoundToSecond(DateTime)")]
public static DateTime TruncMiliseconds(this DateTime dateTime)

Parameters

dateTime DateTime

Returns

DateTime

YearLastTwoDigits(int)

public static string YearLastTwoDigits(this int year)

Parameters

year int

Returns

string