Energy Core Library
Energy.Base.Clock Class Reference

Date and time More...

Classes

class  Duration
 
class  Interval
 

Public Member Functions

bool IsLeapYear (int year)
 Sample subroutine to calculate if a year is a leap year. More...
 

Static Public Member Functions

static double GetUnixTime (DateTime stamp)
 Return time as unix time More...
 
static DateTime GetDateTime (double unix)
 Return unix time as DateTime More...
 
static double GetUnixTime (DateTime stamp, int yearZero)
 Return time as unix time More...
 
static DateTime GetDateTime (double unix, int yearZero)
 Return unix time as DateTime More...
 
static string GetStampString (DateTime? stamp)
 Represent DateTime as simplified ISO date and time string, i.e. "2016-02-23 22:34:10" More...
 
static string GetDateString (DateTime? stamp)
 Represent DateTime as simplified ISO date string, i.e. "2016-02-23" More...
 
static string GetTimeString (DateTime? stamp)
 Represent DateTime as simplified ISO time string, i.e. "22:39:07.350" More...
 
static string GetTimeString (TimeSpan? span)
 Represent TimeSpan as simplified ISO time string with total hours, like "01:07.350", or "123:01:02" More...
 
static string GetISO8601 (DateTime? stamp)
 Represent date and time strictly according to ISO 8601 standard with "T" for time, "Z" for UTC and "+/-" for time zone. More...
 
static string GetZoneString (DateTime? stamp)
 Represent date and time as ISO readable format with zone setting, like "2016-03-02 12:00:01.340 +01:00". If day is not set (equal to "0001-01-01", only time will be returned. Milliseconds are optional. More...
 
static DateTime Parse (string text)
 Parse stamp string More...
 
static DateTime Truncate (DateTime dateTime, int precision)
 Truncate DateTime to desired decimal precision of seconds More...
 
static DateTime Truncate (DateTime dateTime)
 Truncate DateTime to whole seconds More...
 
static TimeSpan Truncate (TimeSpan timeSpan, int precision)
 Truncate TimeSpan to desired decimal precision of seconds More...
 
static DateTime Round (DateTime dateTime, int precision)
 Round DateTime to desired decimal precision of seconds More...
 
static DateTime Round (DateTime dateTime)
 Round DateTime to whole seconds More...
 
static TimeSpan Round (TimeSpan timeSpan, int precision)
 Round TimeSpan to desired decimal precision of seconds More...
 
static DateTime SetDate (DateTime? value, int year, int month, int day)
 
static DateTime SetDate (DateTime value, int year, int month, int day)
 

Static Public Attributes

static readonly TimeSpan Midday = TimeSpan.FromHours(12)
 

Properties

static string CurrentTime [get]
 Return current time in 24h/ms format, i.e. "12:33:15.176" More...
 
static string CurrentTimeShort [get]
 Return current time in 24h/ms format, i.e. "12:33:15" More...
 
static string CurrentTimeMilliseconds [get]
 Return current time in 24h/ms format, i.e. "12:33:15.123" More...
 
static string CurrentTimeMicroseconds [get]
 Return current time in 24h/ms format, i.e. "12:33:15.123456" More...
 
static string CurrentTimeUtc [get]
 Return current time in 24h/ms format, i.e. "12:33:15.176" More...
 
static string CurrentUtcTimeShort [get]
 Return current time in 24h/ms format, i.e. "12:33:15" More...
 
static string CurrentTimeUtcMilliseconds [get]
 Return current time in 24h/ms format, i.e. "12:33:15.123" More...
 
static string CurrentTimeUtcMicroseconds [get]
 Return current time in 24h/ms format, i.e. "12:33:15.123456" More...
 
static double CurrentUnixTime [get]
 Return current time in unix time format, i.e. 1461477755.353 More...
 
static Regex DateRegex [get]
 Singleton More...
 
static Regex TimeRegex [get]
 Singleton More...
 

Detailed Description

Date and time

Member Function Documentation

◆ GetDateString()

static string Energy.Base.Clock.GetDateString ( DateTime?  stamp)
static

Represent DateTime as simplified ISO date string, i.e. "2016-02-23"

Parameters
stampDateTime?
Returns
Date string, empty if null or equal to DateTime.MinValue

◆ GetDateTime() [1/2]

static DateTime Energy.Base.Clock.GetDateTime ( double  unix)
static

Return unix time as DateTime

Parameters
unixUnix time
Returns
DateTime

◆ GetDateTime() [2/2]

static DateTime Energy.Base.Clock.GetDateTime ( double  unix,
int  yearZero 
)
static

Return unix time as DateTime

Parameters
unixUnix time
yearZeroYear of zero value, 1970 for unix
Returns
DateTime

◆ GetISO8601()

static string Energy.Base.Clock.GetISO8601 ( DateTime?  stamp)
static

Represent date and time strictly according to ISO 8601 standard with "T" for time, "Z" for UTC and "+/-" for time zone.

Parameters
stamp
Returns

◆ GetStampString()

static string Energy.Base.Clock.GetStampString ( DateTime?  stamp)
static

Represent DateTime as simplified ISO date and time string, i.e. "2016-02-23 22:34:10"

Parameters
stampDateTime?
Returns
Date and time string, time string if date was not specified, empty if null or equal to DateTime.MinValue

◆ GetTimeString() [1/2]

static string Energy.Base.Clock.GetTimeString ( DateTime?  stamp)
static

Represent DateTime as simplified ISO time string, i.e. "22:39:07.350"

Parameters
stampDateTime?
Returns
Date string, empty if null or equal to DateTime.MinValue

◆ GetTimeString() [2/2]

static string Energy.Base.Clock.GetTimeString ( TimeSpan?  span)
static

Represent TimeSpan as simplified ISO time string with total hours, like "01:07.350", or "123:01:02"

Parameters
spanTimeSpan?
Returns
Time string, empty if null or equal to TimeSpan.MinValue

◆ GetUnixTime() [1/2]

static double Energy.Base.Clock.GetUnixTime ( DateTime  stamp)
static

Return time as unix time

Parameters
stamp
Returns

◆ GetUnixTime() [2/2]

static double Energy.Base.Clock.GetUnixTime ( DateTime  stamp,
int  yearZero 
)
static

Return time as unix time

Parameters
stamp
yearZeroYear of zero value, 1970 for unix
Returns

◆ GetZoneString()

static string Energy.Base.Clock.GetZoneString ( DateTime?  stamp)
static

Represent date and time as ISO readable format with zone setting, like "2016-03-02 12:00:01.340 +01:00". If day is not set (equal to "0001-01-01", only time will be returned. Milliseconds are optional.

Parameters
stampDate and time
Returns
Date, time and zone ISO readable string

◆ IsLeapYear()

bool Energy.Base.Clock.IsLeapYear ( int  year)

Sample subroutine to calculate if a year is a leap year.

Parameters
yearYear
Returns
True if a year is a leap year

◆ Parse()

static DateTime Energy.Base.Clock.Parse ( string  text)
static

Parse stamp string

Parameters
text
Returns

◆ Round() [1/3]

static DateTime Energy.Base.Clock.Round ( DateTime  dateTime,
int  precision 
)
static

Round DateTime to desired decimal precision of seconds

Parameters
dateTime
precision
Returns

◆ Round() [2/3]

static DateTime Energy.Base.Clock.Round ( DateTime  dateTime)
static

Round DateTime to whole seconds

Parameters
dateTime
Returns

◆ Round() [3/3]

static TimeSpan Energy.Base.Clock.Round ( TimeSpan  timeSpan,
int  precision 
)
static

Round TimeSpan to desired decimal precision of seconds

Parameters
timeSpan
precision
Returns

◆ SetDate() [1/2]

static DateTime Energy.Base.Clock.SetDate ( DateTime?  value,
int  year,
int  month,
int  day 
)
static

◆ SetDate() [2/2]

static DateTime Energy.Base.Clock.SetDate ( DateTime  value,
int  year,
int  month,
int  day 
)
static

◆ Truncate() [1/3]

static DateTime Energy.Base.Clock.Truncate ( DateTime  dateTime,
int  precision 
)
static

Truncate DateTime to desired decimal precision of seconds

Parameters
dateTime
precision
Returns

◆ Truncate() [2/3]

static DateTime Energy.Base.Clock.Truncate ( DateTime  dateTime)
static

Truncate DateTime to whole seconds

Parameters
dateTime
Returns

◆ Truncate() [3/3]

static TimeSpan Energy.Base.Clock.Truncate ( TimeSpan  timeSpan,
int  precision 
)
static

Truncate TimeSpan to desired decimal precision of seconds

Parameters
timeSpan
precision
Returns

Member Data Documentation

◆ Midday

readonly TimeSpan Energy.Base.Clock.Midday = TimeSpan.FromHours(12)
static

Property Documentation

◆ CurrentTime

string Energy.Base.Clock.CurrentTime
staticget

Return current time in 24h/ms format, i.e. "12:33:15.176"

◆ CurrentTimeMicroseconds

string Energy.Base.Clock.CurrentTimeMicroseconds
staticget

Return current time in 24h/ms format, i.e. "12:33:15.123456"

◆ CurrentTimeMilliseconds

string Energy.Base.Clock.CurrentTimeMilliseconds
staticget

Return current time in 24h/ms format, i.e. "12:33:15.123"

◆ CurrentTimeShort

string Energy.Base.Clock.CurrentTimeShort
staticget

Return current time in 24h/ms format, i.e. "12:33:15"

◆ CurrentTimeUtc

string Energy.Base.Clock.CurrentTimeUtc
staticget

Return current time in 24h/ms format, i.e. "12:33:15.176"

◆ CurrentTimeUtcMicroseconds

string Energy.Base.Clock.CurrentTimeUtcMicroseconds
staticget

Return current time in 24h/ms format, i.e. "12:33:15.123456"

◆ CurrentTimeUtcMilliseconds

string Energy.Base.Clock.CurrentTimeUtcMilliseconds
staticget

Return current time in 24h/ms format, i.e. "12:33:15.123"

◆ CurrentUnixTime

double Energy.Base.Clock.CurrentUnixTime
staticget

Return current time in unix time format, i.e. 1461477755.353

Returns

◆ CurrentUtcTimeShort

string Energy.Base.Clock.CurrentUtcTimeShort
staticget

Return current time in 24h/ms format, i.e. "12:33:15"

◆ DateRegex

Regex Energy.Base.Clock.DateRegex
staticget

Singleton

◆ TimeRegex

Regex Energy.Base.Clock.TimeRegex
staticget

Singleton


The documentation for this class was generated from the following file: