C# Class GSF.DateTimeExtensions

Defines extension functions related to Date/Time manipulation.
Afficher le fichier Open project: GridProtectionAlliance/gsf

Méthodes publiques

Méthode 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 méthode

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.
Résultat string

AbbreviatedWeekdayName() public static méthode

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.
Résultat string

BaselinedTimestamp() public static méthode

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. ///
Résultat System.DateTime

DistanceBeyondSecond() public static méthode

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

LocalTimeIsValid() public static méthode

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.
Résultat bool

LocalTimeTo() public static méthode

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.
Résultat System.DateTime

LocalTimeTo() public static méthode

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.
Résultat System.DateTime

LocalTimeToCentralTime() public static méthode

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.
Résultat System.DateTime

LocalTimeToEasternTime() public static méthode

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.
Résultat System.DateTime

LocalTimeToMountainTime() public static méthode

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.
Résultat System.DateTime

LocalTimeToPacificTime() public static méthode

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.
Résultat System.DateTime

LocalTimeToUniversalTime() public static méthode

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.
Résultat System.DateTime

MonthName() public static méthode

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.
Résultat string

ShortWeekdayName() public static méthode

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.
Résultat string

TimeIsValid() public static méthode

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.
Résultat bool

TimeZoneToTimeZone() public static méthode

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.
Résultat System.DateTime

TimeZoneToTimeZone() public static méthode

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.
Résultat System.DateTime

UniversalTimeTo() public static méthode

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.
Résultat System.DateTime

UniversalTimeTo() public static méthode

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.
Résultat System.DateTime

UniversalTimeToCentralTime() public static méthode

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.
Résultat System.DateTime

UniversalTimeToEasternTime() public static méthode

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.
Résultat System.DateTime

UniversalTimeToMountainTime() public static méthode

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.
Résultat System.DateTime

UniversalTimeToPacificTime() public static méthode

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.
Résultat System.DateTime

UtcTimeIsValid() public static méthode

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.
Résultat bool

WeekdayName() public static méthode

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.
Résultat string