C# Class GSF.DateTimeExtensions

Defines extension functions related to Date/Time manipulation.
Exibir arquivo Open project: GridProtectionAlliance/gsf

Public Methods

Method Description
AbbreviatedMonthName ( this timestamp ) : string

Gets the abbreviated month name for month of the timestamp.

AbbreviatedWeekdayName ( this timestamp ) : string

Gets the abbreviated weekday name for weekday of the timestamp.

BaselinedTimestamp ( this timestamp, BaselineTimeInterval interval ) : System.DateTime

Creates a baselined timestamp which begins at the specified time interval.

Baselining to the BaselineTimeInterval.Second would return the DateTime value starting at zero milliseconds.
Baselining to the BaselineTimeInterval.Minute would return the DateTime value starting at zero seconds and milliseconds.
Baselining to the BaselineTimeInterval.Hour would return the DateTime value starting at zero minutes, seconds and milliseconds.
Baselining to the BaselineTimeInterval.Day would return the DateTime value starting at zero hours, minutes, seconds and milliseconds.
Baselining to the BaselineTimeInterval.Month would return the DateTime value starting at day one, zero hours, minutes, seconds and milliseconds.
Baselining to the BaselineTimeInterval.Year would return the DateTime value starting at month one, day one, zero hours, minutes, seconds and milliseconds.

DistanceBeyondSecond ( this timestamp ) : Ticks

Gets the distance, in Ticks, beyond the top of the timestamp second.

LocalTimeIsValid ( this localTime, double lagTime, double leadTime ) : bool

Determines if the specified local time is valid, by comparing it to the system clock.

Time is considered valid if it exists within the specified lag time/lead time range of current time.

Note that lag time and lead time must be greater than zero, but can be set to sub-second intervals.

LocalTimeTo ( this timestamp, TimeZoneInfo destinationTimeZone ) : System.DateTime

Converts given local time to time in specified time zone.

LocalTimeTo ( this timestamp, string destinationTimeZoneStandardName ) : System.DateTime

Converts given local time to time in specified time zone.

LocalTimeToCentralTime ( this timestamp ) : System.DateTime

Converts given local time to Central time.

LocalTimeToEasternTime ( this timestamp ) : System.DateTime

Converts given local time to Eastern time.

LocalTimeToMountainTime ( this timestamp ) : System.DateTime

Converts given local time to Mountain time.

LocalTimeToPacificTime ( this timestamp ) : System.DateTime

Converts given local time to Pacific time.

LocalTimeToUniversalTime ( this timestamp ) : System.DateTime

Converts given local time to Universally Coordinated Time (a.k.a., Greenwich Meridian Time).

This function is only provided for the sake of completeness. All it does is call the "ToUniversalTime" property on the given timestamp.

MonthName ( this timestamp ) : string

Gets the full month name for month of the timestamp.

ShortWeekdayName ( this timestamp ) : string

Gets the shortest weekday name for weekday of the timestamp.

TimeIsValid ( this testTime, System.DateTime currentTime, double lagTime, double leadTime ) : bool

Determines if time is valid, by comparing it to the specified current time.

Time is considered valid if it exists within the specified lag time/lead time range of current time.

Note that lag time and lead time must be greater than zero, but can be set to sub-second intervals.

TimeZoneToTimeZone ( this timestamp, TimeZoneInfo sourceTimeZone, TimeZoneInfo destinationTimeZone ) : System.DateTime

Converts given timestamp from one time zone to another.

TimeZoneToTimeZone ( this timestamp, string sourceTimeZoneStandardName, string destinationTimeZoneStandardName ) : System.DateTime

Converts given timestamp from one time zone to another using standard names for time zones.

UniversalTimeTo ( this universalTimestamp, TimeZoneInfo destinationTimeZone ) : System.DateTime

Converts the specified Universally Coordinated Time timestamp to timestamp in specified time zone.

UniversalTimeTo ( this universalTimestamp, string destinationTimeZoneStandardName ) : System.DateTime

Converts the specified Universally Coordinated Time timestamp to timestamp in specified time zone.

UniversalTimeToCentralTime ( this universalTimestamp ) : System.DateTime

Converts the specified Universally Coordinated Time timestamp to Central time timestamp.

UniversalTimeToEasternTime ( this universalTimestamp ) : System.DateTime

Converts the specified Universally Coordinated Time timestamp to Eastern time timestamp.

UniversalTimeToMountainTime ( this universalTimestamp ) : System.DateTime

Converts the specified Universally Coordinated Time timestamp to Mountain time timestamp.

UniversalTimeToPacificTime ( this universalTimestamp ) : System.DateTime

Converts the specified Universally Coordinated Time timestamp to Pacific time timestamp.

UtcTimeIsValid ( this utcTime, double lagTime, double leadTime ) : bool

Determines if the specified UTC time is valid, by comparing it to the system clock.

Time is considered valid if it exists within the specified lag time/lead time range of current time.

Note that lag time and lead time must be greater than zero, but can be set to sub-second intervals.

WeekdayName ( this timestamp ) : string

Gets the full weekday name for weekday of the timestamp.

Method Details

AbbreviatedMonthName() public static method

Gets the abbreviated month name for month of the timestamp.
public static AbbreviatedMonthName ( this timestamp ) : string
timestamp this Timestamp from which month name is extracted.
return string

AbbreviatedWeekdayName() public static method

Gets the abbreviated weekday name for weekday of the timestamp.
public static AbbreviatedWeekdayName ( this timestamp ) : string
timestamp this Timestamp from which weekday name is extracted.
return string

BaselinedTimestamp() public static method

Creates a baselined timestamp which begins at the specified time interval.
Baselining to the BaselineTimeInterval.Second would return the DateTime value starting at zero milliseconds.
Baselining to the BaselineTimeInterval.Minute would return the DateTime value starting at zero seconds and milliseconds.
Baselining to the BaselineTimeInterval.Hour would return the DateTime value starting at zero minutes, seconds and milliseconds.
Baselining to the BaselineTimeInterval.Day would return the DateTime value starting at zero hours, minutes, seconds and milliseconds.
Baselining to the BaselineTimeInterval.Month would return the DateTime value starting at day one, zero hours, minutes, seconds and milliseconds.
Baselining to the BaselineTimeInterval.Year would return the DateTime value starting at month one, day one, zero hours, minutes, seconds and milliseconds.
public static BaselinedTimestamp ( this timestamp, BaselineTimeInterval interval ) : System.DateTime
timestamp this Timestamp to baseline.
interval BaselineTimeInterval /// to which should be baselined. ///
return System.DateTime

DistanceBeyondSecond() public static method

Gets the distance, in Ticks, beyond the top of the timestamp second.
public static DistanceBeyondSecond ( this timestamp ) : Ticks
timestamp this Timestamp to evaluate.
return Ticks

LocalTimeIsValid() public static method

Determines if the specified local time is valid, by comparing it to the system clock.

Time is considered valid if it exists within the specified lag time/lead time range of current time.

Note that lag time and lead time must be greater than zero, but can be set to sub-second intervals.

LagTime and LeadTime must be greater than zero, but can /// be less than one.
public static LocalTimeIsValid ( this localTime, double lagTime, double leadTime ) : bool
localTime this Time to test for validity.
lagTime double The allowed lag time, in seconds, before assuming time is too old to be valid.
leadTime double The allowed lead time, in seconds, before assuming time is too advanced to be /// valid.
return bool

LocalTimeTo() public static method

Converts given local time to time in specified time zone.
public static LocalTimeTo ( this timestamp, TimeZoneInfo destinationTimeZone ) : System.DateTime
timestamp this Timestamp in local time to be converted to time in specified time zone.
destinationTimeZone System.TimeZoneInfo Desired end time zone for given timestamp.
return System.DateTime

LocalTimeTo() public static method

Converts given local time to time in specified time zone.
public static LocalTimeTo ( this timestamp, string destinationTimeZoneStandardName ) : System.DateTime
timestamp this Timestamp in local time to be converted to time in specified time zone.
destinationTimeZoneStandardName string Standard name of desired end time zone for given /// timestamp.
return System.DateTime

LocalTimeToCentralTime() public static method

Converts given local time to Central time.
public static LocalTimeToCentralTime ( this timestamp ) : System.DateTime
timestamp this Timestamp in local time to be converted to Central time.
return System.DateTime

LocalTimeToEasternTime() public static method

Converts given local time to Eastern time.
public static LocalTimeToEasternTime ( this timestamp ) : System.DateTime
timestamp this Timestamp in local time to be converted to Eastern time.
return System.DateTime

LocalTimeToMountainTime() public static method

Converts given local time to Mountain time.
public static LocalTimeToMountainTime ( this timestamp ) : System.DateTime
timestamp this Timestamp in local time to be converted to Mountain time.
return System.DateTime

LocalTimeToPacificTime() public static method

Converts given local time to Pacific time.
public static LocalTimeToPacificTime ( this timestamp ) : System.DateTime
timestamp this Timestamp in local time to be converted to Pacific time.
return System.DateTime

LocalTimeToUniversalTime() public static method

Converts given local time to Universally Coordinated Time (a.k.a., Greenwich Meridian Time).
This function is only provided for the sake of completeness. All it does is call the "ToUniversalTime" property on the given timestamp.
public static LocalTimeToUniversalTime ( this timestamp ) : System.DateTime
timestamp this Timestamp in local time to be converted to Universal time.
return System.DateTime

MonthName() public static method

Gets the full month name for month of the timestamp.
public static MonthName ( this timestamp ) : string
timestamp this Timestamp from which month name is extracted.
return string

ShortWeekdayName() public static method

Gets the shortest weekday name for weekday of the timestamp.
public static ShortWeekdayName ( this timestamp ) : string
timestamp this Timestamp from which weekday name is extracted.
return string

TimeIsValid() public static method

Determines if time is valid, by comparing it to the specified current time.

Time is considered valid if it exists within the specified lag time/lead time range of current time.

Note that lag time and lead time must be greater than zero, but can be set to sub-second intervals.

LagTime and LeadTime must be greater than zero, but can /// be less than one.
public static TimeIsValid ( this testTime, System.DateTime currentTime, double lagTime, double leadTime ) : bool
testTime this Time to test for validity.
currentTime System.DateTime Specified current time (e.g., could be Date.Now or Date.UtcNow).
lagTime double The allowed lag time, in seconds, before assuming time is too old to be valid.
leadTime double The allowed lead time, in seconds, before assuming time is too advanced to be /// valid.
return bool

TimeZoneToTimeZone() public static method

Converts given timestamp from one time zone to another.
public static TimeZoneToTimeZone ( this timestamp, TimeZoneInfo sourceTimeZone, TimeZoneInfo destinationTimeZone ) : System.DateTime
timestamp this Timestamp in source time zone to be converted to time in destination time /// zone.
sourceTimeZone System.TimeZoneInfo Time zone for given source timestamp.
destinationTimeZone System.TimeZoneInfo Desired end time zone for given source timestamp.
return System.DateTime

TimeZoneToTimeZone() public static method

Converts given timestamp from one time zone to another using standard names for time zones.
public static TimeZoneToTimeZone ( this timestamp, string sourceTimeZoneStandardName, string destinationTimeZoneStandardName ) : System.DateTime
timestamp this Timestamp in source time zone to be converted to time in destination time zone.
sourceTimeZoneStandardName string Standard name of time zone for given source timestamp.
destinationTimeZoneStandardName string Standard name of desired end time zone for given source /// timestamp.
return System.DateTime

UniversalTimeTo() public static method

Converts the specified Universally Coordinated Time timestamp to timestamp in specified time zone.
public static UniversalTimeTo ( this universalTimestamp, TimeZoneInfo destinationTimeZone ) : System.DateTime
universalTimestamp this The Universally Coordinated Time timestamp that is to be converted.
destinationTimeZone System.TimeZoneInfo The time zone to which the Universally Coordinated Time timestamp /// is to be converted to.
return System.DateTime

UniversalTimeTo() public static method

Converts the specified Universally Coordinated Time timestamp to timestamp in specified time zone.
public static UniversalTimeTo ( this universalTimestamp, string destinationTimeZoneStandardName ) : System.DateTime
universalTimestamp this The Universally Coordinated Time timestamp that is to be converted.
destinationTimeZoneStandardName string The time zone standard name to which the Universally /// Coordinated Time timestamp is to be converted to.
return System.DateTime

UniversalTimeToCentralTime() public static method

Converts the specified Universally Coordinated Time timestamp to Central time timestamp.
public static UniversalTimeToCentralTime ( this universalTimestamp ) : System.DateTime
universalTimestamp this The Universally Coordinated Time timestamp that is to be converted.
return System.DateTime

UniversalTimeToEasternTime() public static method

Converts the specified Universally Coordinated Time timestamp to Eastern time timestamp.
public static UniversalTimeToEasternTime ( this universalTimestamp ) : System.DateTime
universalTimestamp this The Universally Coordinated Time timestamp that is to be converted.
return System.DateTime

UniversalTimeToMountainTime() public static method

Converts the specified Universally Coordinated Time timestamp to Mountain time timestamp.
public static UniversalTimeToMountainTime ( this universalTimestamp ) : System.DateTime
universalTimestamp this The Universally Coordinated Time timestamp that is to be converted.
return System.DateTime

UniversalTimeToPacificTime() public static method

Converts the specified Universally Coordinated Time timestamp to Pacific time timestamp.
public static UniversalTimeToPacificTime ( this universalTimestamp ) : System.DateTime
universalTimestamp this The Universally Coordinated Time timestamp that is to be converted.
return System.DateTime

UtcTimeIsValid() public static method

Determines if the specified UTC time is valid, by comparing it to the system clock.

Time is considered valid if it exists within the specified lag time/lead time range of current time.

Note that lag time and lead time must be greater than zero, but can be set to sub-second intervals.

LagTime and LeadTime must be greater than zero, but can /// be less than one.
public static UtcTimeIsValid ( this utcTime, double lagTime, double leadTime ) : bool
utcTime this UTC time to test for validity.
lagTime double The allowed lag time, in seconds, before assuming time is too old to be valid.
leadTime double The allowed lead time, in seconds, before assuming time is too advanced to be /// valid.
return bool

WeekdayName() public static method

Gets the full weekday name for weekday of the timestamp.
public static WeekdayName ( this timestamp ) : string
timestamp this Timestamp from which weekday name is extracted.
return string