C# Класс GSF.DateTimeExtensions

Defines extension functions related to Date/Time manipulation.
Показать файл Открыть проект

Открытые методы

Метод Описание
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.

Описание методов

AbbreviatedMonthName() публичный статический Метод

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.
Результат string

AbbreviatedWeekdayName() публичный статический Метод

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.
Результат string

BaselinedTimestamp() публичный статический Метод

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. ///
Результат System.DateTime

DistanceBeyondSecond() публичный статический Метод

Gets the distance, in Ticks, beyond the top of the timestamp second.
public static DistanceBeyondSecond ( this timestamp ) : Ticks
timestamp this Timestamp to evaluate.
Результат Ticks

LocalTimeIsValid() публичный статический Метод

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.
Результат bool

LocalTimeTo() публичный статический Метод

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.
Результат System.DateTime

LocalTimeTo() публичный статический Метод

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.
Результат System.DateTime

LocalTimeToCentralTime() публичный статический Метод

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.
Результат System.DateTime

LocalTimeToEasternTime() публичный статический Метод

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.
Результат System.DateTime

LocalTimeToMountainTime() публичный статический Метод

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.
Результат System.DateTime

LocalTimeToPacificTime() публичный статический Метод

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.
Результат System.DateTime

LocalTimeToUniversalTime() публичный статический Метод

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.
Результат System.DateTime

MonthName() публичный статический Метод

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.
Результат string

ShortWeekdayName() публичный статический Метод

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.
Результат string

TimeIsValid() публичный статический Метод

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.
Результат bool

TimeZoneToTimeZone() публичный статический Метод

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.
Результат System.DateTime

TimeZoneToTimeZone() публичный статический Метод

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.
Результат System.DateTime

UniversalTimeTo() публичный статический Метод

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.
Результат System.DateTime

UniversalTimeTo() публичный статический Метод

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.
Результат System.DateTime

UniversalTimeToCentralTime() публичный статический Метод

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.
Результат System.DateTime

UniversalTimeToEasternTime() публичный статический Метод

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.
Результат System.DateTime

UniversalTimeToMountainTime() публичный статический Метод

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.
Результат System.DateTime

UniversalTimeToPacificTime() публичный статический Метод

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.
Результат System.DateTime

UtcTimeIsValid() публичный статический Метод

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.
Результат bool

WeekdayName() публичный статический Метод

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.
Результат string