Show / Hide Table of Contents

Struct TimeStamp

Use this to get extremely fast timestamping when:

  1. Your primary purpose is fast, efficient storage of exact times, across multiple timezones.
  2. You run very frequent comparisons of timestamps, possibly as a way of comparing across multiple timezones.
  3. You DON'T often need to extract string representations, or get the day/month/year/hour/minute/second properties (compute intensive).
Implements
IComparable<TimeStamp>
IEquatable<TimeStamp>
Namespace: FFT.TimeStamps
Assembly: FFT.TimeStamps.dll
Syntax
public struct TimeStamp : IComparable<TimeStamp>, IEquatable<TimeStamp>

Constructors

| Improve this Doc View Source

TimeStamp(DateTimeOffset)

Initializes a new instance of the TimeStamp struct from the given .

Declaration
public TimeStamp(DateTimeOffset at)
Parameters
Type Name Description
DateTimeOffset at
| Improve this Doc View Source

TimeStamp(DateStamp, TimeSpan, TimeZoneInfo)

Initializes a new instance of the TimeStamp struct at the date and timeOfDay in the given timeZone. Ambiguous times are considered to be in the standard (not daylight savings) offset. Invalid times are considered to be in the standard (not daylight savings) offset. Compute intensive. Don't use it in a hot path.

Declaration
public TimeStamp(DateStamp date, TimeSpan timeOfDay, TimeZoneInfo timeZone)
Parameters
Type Name Description
DateStamp date
TimeSpan timeOfDay
TimeZoneInfo timeZone
| Improve this Doc View Source

TimeStamp(Int64)

Initializes a new instance of the TimeStamp struct with the given number of ticks UTC.

Declaration
public TimeStamp(long ticksUtc)
Parameters
Type Name Description
System.Int64 ticksUtc
| Improve this Doc View Source

TimeStamp(Int64, TimeZoneInfo)

Initializes a new instance of the TimeStamp struct from the ticks in the given TimeZone. Ambiguous times are considered to be in the standard (not daylight savings) offset. Invalid times are considered to be in the standard (not daylight savings) offset. Compute intensive. Don't use it in a hot path.

Declaration
public TimeStamp(long ticksTimeZone, TimeZoneInfo timeZone)
Parameters
Type Name Description
System.Int64 ticksTimeZone
TimeZoneInfo timeZone

Fields

| Improve this Doc View Source

MaxValue

Contains the maximum possible value of a TimeStamp.

Declaration
public static readonly TimeStamp MaxValue
Field Value
Type Description
TimeStamp
| Improve this Doc View Source

MinValue

Contains the minimum possible value of a TimeStamp.

Declaration
public static readonly TimeStamp MinValue
Field Value
Type Description
TimeStamp
| Improve this Doc View Source

TicksUtc

The number of ticks in UTC timezone.

Declaration
public readonly long TicksUtc
Field Value
Type Description
System.Int64
| Improve this Doc View Source

UnixEpoch

Contains the timestamp at 0 unix time, Midnight, 1 January 1970.

Declaration
public static readonly TimeStamp UnixEpoch
Field Value
Type Description
TimeStamp

Properties

| Improve this Doc View Source

Now

Gets the current time as a TimeStamp.

Declaration
public static TimeStamp Now { get; }
Property Value
Type Description
TimeStamp

Methods

| Improve this Doc View Source

Add(TimeSpan)

Returns a TimeStamp advanced by the given timeSpan.

Declaration
public TimeStamp Add(TimeSpan timeSpan)
Parameters
Type Name Description
TimeSpan timeSpan

The amount of ABSOLUTE time to advance the TimeStamp.

Returns
Type Description
TimeStamp
| Improve this Doc View Source

Add(TimeSpan, TimeZoneInfo)

Returns a TimeStamp advanced by the given timeSpan in the given timeZone. Compute intensive. Don't use in a hot path.

Declaration
public TimeStamp Add(TimeSpan timeSpan, TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeSpan timeSpan

The amount of TIMEZONE time to advance the TimeStamp.

TimeZoneInfo timeZone

The timezone of the clock being adjusted.

Returns
Type Description
TimeStamp
| Improve this Doc View Source

AddDays(Double)

Returns a TimeStamp advanced by the given number of days.

Declaration
public TimeStamp AddDays(double days)
Parameters
Type Name Description
System.Double days

The number of days of ABSOLUTE time to advance the TimeStamp.

Returns
Type Description
TimeStamp
| Improve this Doc View Source

AddDays(Double, TimeZoneInfo)

Returns a TimeStamp advanced by the given number of days in the given timeZone. Compute intensive. Don't use in a hot path.

Declaration
public TimeStamp AddDays(double days, TimeZoneInfo timeZone)
Parameters
Type Name Description
System.Double days

The number of days of TIMEZONE time to advance the TimeStamp.

TimeZoneInfo timeZone

The timezone of the clock being adjusted.

Returns
Type Description
TimeStamp
| Improve this Doc View Source

AddHours(Double)

Returns a TimeStamp advanced by the given number of hours.

Declaration
public TimeStamp AddHours(double hours)
Parameters
Type Name Description
System.Double hours

The number of hours of ABSOLUTE time to advance the TimeStamp.

Returns
Type Description
TimeStamp
| Improve this Doc View Source

AddHours(Double, TimeZoneInfo)

Returns a TimeStamp advanced by the given number of hours in the given timeZone. Compute intensive. Don't use in a hot path.

Declaration
public TimeStamp AddHours(double hours, TimeZoneInfo timeZone)
Parameters
Type Name Description
System.Double hours

The number of hours of TIMEZONE time to advance the TimeStamp.

TimeZoneInfo timeZone

The timezone of the clock being adjusted.

Returns
Type Description
TimeStamp
| Improve this Doc View Source

AddMilliseconds(Double)

Returns a TimeStamp advanced by the given number of milliseconds.

Declaration
public TimeStamp AddMilliseconds(double milliseconds)
Parameters
Type Name Description
System.Double milliseconds

The number of milliseconds of ABSOLUTE time to advance the TimeStamp.

Returns
Type Description
TimeStamp
| Improve this Doc View Source

AddMilliseconds(Double, TimeZoneInfo)

Returns a TimeStamp advanced by the given number of milliseconds in the given timeZone. Compute intensive. Don't use in a hot path.

Declaration
public TimeStamp AddMilliseconds(double milliseconds, TimeZoneInfo timeZone)
Parameters
Type Name Description
System.Double milliseconds

The number of milliseconds of TIMEZONE time to advance the TimeStamp.

TimeZoneInfo timeZone

The timezone of the clock being adjusted.

Returns
Type Description
TimeStamp
| Improve this Doc View Source

AddMinutes(Double)

Returns a TimeStamp advanced by the given number of minutes.

Declaration
public TimeStamp AddMinutes(double minutes)
Parameters
Type Name Description
System.Double minutes

The number of minutes of ABSOLUTE time to advance the TimeStamp.

Returns
Type Description
TimeStamp
| Improve this Doc View Source

AddMinutes(Double, TimeZoneInfo)

Returns a TimeStamp advanced by the given number of minutes in the given timeZone. Compute intensive. Don't use in a hot path.

Declaration
public TimeStamp AddMinutes(double minutes, TimeZoneInfo timeZone)
Parameters
Type Name Description
System.Double minutes

The number of minutes of TIMEZONE time to advance the TimeStamp.

TimeZoneInfo timeZone

The timezone of the clock being adjusted.

Returns
Type Description
TimeStamp
| Improve this Doc View Source

AddSeconds(Double)

Returns a TimeStamp advanced by the given number of seconds.

Declaration
public TimeStamp AddSeconds(double seconds)
Parameters
Type Name Description
System.Double seconds

The number of seconds of ABSOLUTE time to advance the TimeStamp.

Returns
Type Description
TimeStamp
| Improve this Doc View Source

AddSeconds(Double, TimeZoneInfo)

Returns a TimeStamp advanced by the given number of seconds in the given timeZone. Compute intensive. Don't use in a hot path.

Declaration
public TimeStamp AddSeconds(double seconds, TimeZoneInfo timeZone)
Parameters
Type Name Description
System.Double seconds

The number of seconds of TIMEZONE time to advance the TimeStamp.

TimeZoneInfo timeZone

The timezone of the clock being adjusted.

Returns
Type Description
TimeStamp
| Improve this Doc View Source

AddTicks(Int64)

Creates a new TimeStamp by adding the given number of ticks to the instance.

Declaration
public TimeStamp AddTicks(long ticks)
Parameters
Type Name Description
System.Int64 ticks
Returns
Type Description
TimeStamp
| Improve this Doc View Source

AddTicks(Int64, TimeZoneInfo)

Returns a TimeStamp advanced by the given number of ticks in the given timeZone. Compute intensive. Don't use in a hot path.

Declaration
public TimeStamp AddTicks(long ticks, TimeZoneInfo timeZone)
Parameters
Type Name Description
System.Int64 ticks

The number of ticks of TIMEZONE time to advance the TimeStamp.

TimeZoneInfo timeZone

The timezone of the clock being adjusted.

Returns
Type Description
TimeStamp
| Improve this Doc View Source

As(TimeZoneInfo)

Calculates a DateTimeOffset adjusted for the given timeZone. Compute intensive. Don't use in a hot path.

Declaration
public DateTimeOffset As(TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeZoneInfo timeZone
Returns
Type Description
DateTimeOffset
| Improve this Doc View Source

AsLocal()

Creates a object offset for the local timezone. Compute intensive. Don't use in a hot path.

Declaration
public DateTimeOffset AsLocal()
Returns
Type Description
DateTimeOffset
| Improve this Doc View Source

AsLocalTicks()

Gets the Ticks property of a clock in the local time zone at the current moment. Compute intensive. Don't use in a hot path.

Declaration
public long AsLocalTicks()
Returns
Type Description
System.Int64
| Improve this Doc View Source

AsOffset(TimeSpan)

Creates a object offset with the given offset.

Declaration
public DateTimeOffset AsOffset(TimeSpan offset)
Parameters
Type Name Description
TimeSpan offset
Returns
Type Description
DateTimeOffset
| Improve this Doc View Source

AsTicks(TimeZoneInfo)

Gets the Ticks property of a clock in the given timeZone at the current moment. Compute intensive. Don't use in a hot path.

Declaration
public long AsTicks(TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeZoneInfo timeZone
Returns
Type Description
System.Int64
| Improve this Doc View Source

AsUtc()

Creates a object offset with zero (UTC) offset.

Declaration
public DateTimeOffset AsUtc()
Returns
Type Description
DateTimeOffset
| Improve this Doc View Source

CompareTo(TimeStamp)

Declaration
public int CompareTo(TimeStamp other)
Parameters
Type Name Description
TimeStamp other
Returns
Type Description
System.Int32
| Improve this Doc View Source

Equals(TimeStamp)

Declaration
public bool Equals(TimeStamp other)
Parameters
Type Name Description
TimeStamp other
Returns
Type Description
System.Boolean
| Improve this Doc View Source

Equals(Object)

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
System.Object obj
Returns
Type Description
System.Boolean
| Improve this Doc View Source

FromUnixMilliseconds(Int64)

Creates a timestamp the given number of milliseconds after midnight, 1 January 1970 UTC.

Declaration
public static TimeStamp FromUnixMilliseconds(long unixMilliseconds)
Parameters
Type Name Description
System.Int64 unixMilliseconds
Returns
Type Description
TimeStamp
| Improve this Doc View Source

FromUnixMilliseconds(Int64, TimeZoneInfo)

Creates a timestamp the given number of milliseconds after midnight, 1 January 1970, in the specified timezone. Compute intensive. Do not use in a hot path.

Declaration
public static TimeStamp FromUnixMilliseconds(long unixMilliseconds, TimeZoneInfo timeZone)
Parameters
Type Name Description
System.Int64 unixMilliseconds
TimeZoneInfo timeZone
Returns
Type Description
TimeStamp
| Improve this Doc View Source

FromUnixSeconds(Int64)

Creates a timestamp the given number of seconds after midnight, 1 January 1970 UTC.

Declaration
public static TimeStamp FromUnixSeconds(long unixSeconds)
Parameters
Type Name Description
System.Int64 unixSeconds
Returns
Type Description
TimeStamp
| Improve this Doc View Source

FromUnixSeconds(Int64, TimeZoneInfo)

Creates a timestamp the given number of seconds after midnight, 1 January 1970, in the specified timezone. Compute intensive. Do not use in a hot path.

Declaration
public static TimeStamp FromUnixSeconds(long unixSeconds, TimeZoneInfo timeZone)
Parameters
Type Name Description
System.Int64 unixSeconds
TimeZoneInfo timeZone
Returns
Type Description
TimeStamp
| Improve this Doc View Source

GetDate()

Gets the date of the current moment in the utc timezone.

Declaration
public DateStamp GetDate()
Returns
Type Description
DateStamp
| Improve this Doc View Source

GetDate(TimeZoneInfo)

Gets the date of the current moment in the given timeZone. Compute intensive. Do not use in a hot path.

Declaration
public DateStamp GetDate(TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeZoneInfo timeZone
Returns
Type Description
DateStamp
| Improve this Doc View Source

GetHashCode()

Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32
| Improve this Doc View Source

GetMonth()

Gets the month of the current moment in the utc timezone.

Declaration
public MonthStamp GetMonth()
Returns
Type Description
MonthStamp
| Improve this Doc View Source

GetMonth(TimeZoneInfo)

Gets the month of the current moment in the given timeZone Compute intensive. Do not use in a hot path.

Declaration
public MonthStamp GetMonth(TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeZoneInfo timeZone
Returns
Type Description
MonthStamp
| Improve this Doc View Source

GetNext(TimeOfWeek)

Calculates the moment at timeOfWeek in UTC timezone that occurs at or just after the given timestamp.

Declaration
public TimeStamp GetNext(TimeOfWeek timeOfWeek)
Parameters
Type Name Description
TimeOfWeek timeOfWeek
Returns
Type Description
TimeStamp
| Improve this Doc View Source

GetNext(TimeOfWeek, TimeZoneInfo)

Calculates the moment at timeOfWeek in timeZone that occurs at or just after the given timestamp. Compute intensive. Do not use in a hot path.

Declaration
public TimeStamp GetNext(TimeOfWeek timeOfWeek, TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeOfWeek timeOfWeek
TimeZoneInfo timeZone
Returns
Type Description
TimeStamp
| Improve this Doc View Source

GetNext(TimeSpan)

Calculates the moment at timeOfDay in UTC timezone that occurs at or just after the given timestamp.

Declaration
public TimeStamp GetNext(TimeSpan timeOfDay)
Parameters
Type Name Description
TimeSpan timeOfDay
Returns
Type Description
TimeStamp
| Improve this Doc View Source

GetNext(TimeSpan, TimeZoneInfo)

Calculates the moment at timeOfDay in timeZone that occurs at or just after the given timestamp. Compute intensive. Do not use in a hot path.

Declaration
public TimeStamp GetNext(TimeSpan timeOfDay, TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeSpan timeOfDay
TimeZoneInfo timeZone
Returns
Type Description
TimeStamp
| Improve this Doc View Source

GetPrevious(TimeOfWeek)

Calculates the moment at timeOfWeek in UTC timezone that occurs at or just before the given timestamp.

Declaration
public TimeStamp GetPrevious(TimeOfWeek timeOfWeek)
Parameters
Type Name Description
TimeOfWeek timeOfWeek
Returns
Type Description
TimeStamp
| Improve this Doc View Source

GetPrevious(TimeOfWeek, TimeZoneInfo)

Calculates the moment at timeOfWeek in timeZone that occurs at or just before the given timestamp. Compute intensive. Do not use in a hot path.

Declaration
public TimeStamp GetPrevious(TimeOfWeek timeOfWeek, TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeOfWeek timeOfWeek
TimeZoneInfo timeZone
Returns
Type Description
TimeStamp
| Improve this Doc View Source

GetPrevious(TimeSpan)

Calculates the moment at timeOfDay in UTC timezone that occurs at or just before the given timestamp.

Declaration
public TimeStamp GetPrevious(TimeSpan timeOfDay)
Parameters
Type Name Description
TimeSpan timeOfDay
Returns
Type Description
TimeStamp
| Improve this Doc View Source

GetPrevious(TimeSpan, TimeZoneInfo)

Calculates the moment at timeOfDay in timeZone that occurs at or just before the given timestamp. Compute intensive. Do not use in a hot path.

Declaration
public TimeStamp GetPrevious(TimeSpan timeOfDay, TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeSpan timeOfDay
TimeZoneInfo timeZone
Returns
Type Description
TimeStamp
| Improve this Doc View Source

GetTimeOfDay()

Gets the time of day of the current moment in the utc timezone.

Declaration
public TimeSpan GetTimeOfDay()
Returns
Type Description
TimeSpan
| Improve this Doc View Source

GetTimeOfDay(TimeZoneInfo)

Gets the time of day of the current moment in the given timeZone. Compute intensive. Do not use in a hot path.

Declaration
public TimeSpan GetTimeOfDay(TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeZoneInfo timeZone
Returns
Type Description
TimeSpan
| Improve this Doc View Source

GetTimeOfWeek()

Gets the time of week of the current moment in the utc timezone.

Declaration
public TimeOfWeek GetTimeOfWeek()
Returns
Type Description
TimeOfWeek
| Improve this Doc View Source

GetTimeOfWeek(TimeZoneInfo)

Gets the time of week of the current moment for a clock in the given timeZone. Compute intensive. Do not use in a hot path.

Declaration
public TimeOfWeek GetTimeOfWeek(TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeZoneInfo timeZone
Returns
Type Description
TimeOfWeek
| Improve this Doc View Source

Max(TimeStamp, TimeStamp)

Returns the maximum of the given values.

Declaration
public static TimeStamp Max(TimeStamp t1, TimeStamp t2)
Parameters
Type Name Description
TimeStamp t1
TimeStamp t2
Returns
Type Description
TimeStamp
| Improve this Doc View Source

Max(TimeStamp[])

Returns the maxmimum of the given values. Thrown if values is null or empty.

Declaration
public static TimeStamp Max(params TimeStamp[] values)
Parameters
Type Name Description
TimeStamp[] values
Returns
Type Description
TimeStamp
| Improve this Doc View Source

Min(TimeStamp, TimeStamp)

Returns the minimum of the given values.

Declaration
public static TimeStamp Min(TimeStamp t1, TimeStamp t2)
Parameters
Type Name Description
TimeStamp t1
TimeStamp t2
Returns
Type Description
TimeStamp
| Improve this Doc View Source

Min(TimeStamp[])

Returns the minimum of the given values.

Declaration
public static TimeStamp Min(params TimeStamp[] values)
Parameters
Type Name Description
TimeStamp[] values
Returns
Type Description
TimeStamp
| Improve this Doc View Source

OrValueIfGreater(TimeStamp)

Returns the greater of the two timestamps.

Declaration
public TimeStamp OrValueIfGreater(TimeStamp t)
Parameters
Type Name Description
TimeStamp t
Returns
Type Description
TimeStamp
| Improve this Doc View Source

OrValueIfLesser(TimeStamp)

Returns the lesser of the two timestamps.

Declaration
public TimeStamp OrValueIfLesser(TimeStamp t)
Parameters
Type Name Description
TimeStamp t
Returns
Type Description
TimeStamp
| Improve this Doc View Source

Subtract(TimeStamp)

Calculates the time difference between this time and the given timeStamp.

Declaration
public TimeSpan Subtract(TimeStamp timeStamp)
Parameters
Type Name Description
TimeStamp timeStamp
Returns
Type Description
TimeSpan
| Improve this Doc View Source

Subtract(TimeSpan)

Returns a TimeStamp retarded by the given timeSpan.

Declaration
public TimeStamp Subtract(TimeSpan timeSpan)
Parameters
Type Name Description
TimeSpan timeSpan

The amount of ABSOLUTE time to retard the TimeStamp.

Returns
Type Description
TimeStamp
| Improve this Doc View Source

Subtract(TimeSpan, TimeZoneInfo)

Returns a TimeStamp retarded by the given timeSpan in the given timeZone. Compute intensive. Don't use in a hot path.

Declaration
public TimeStamp Subtract(TimeSpan timeSpan, TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeSpan timeSpan

The amount of TIMEZONE time to retard the TimeStamp.

TimeZoneInfo timeZone

The timezone of the clock being adjusted.

Returns
Type Description
TimeStamp
| Improve this Doc View Source

ToDayCeiling()

Rounds the given timestamp up to the start of the next day, in absolute time. If the timestamp is at an exact day, it returns a copy of the same timestamp. Time zone is completely ignored.

Declaration
public TimeStamp ToDayCeiling()
Returns
Type Description
TimeStamp
| Improve this Doc View Source

ToDayCeiling(TimeZoneInfo)

Rounds the given timestamp up to the start of the day for a clock in the given timeZone. If the current timestamp is already at the exact start of the day, a copy of the same timestamp is returned. Compute intensive. Do not use in a hot path.

Declaration
public TimeStamp ToDayCeiling(TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeZoneInfo timeZone
Returns
Type Description
TimeStamp

A TimeStamp representing the calculated moment in time.

| Improve this Doc View Source

ToDayFloor()

Rounds the given timestamp down to the start of the day, in absolute time. If the timestamp is at an exact day, it returns a copy of the same timestamp. Time zone is completely ignored.

Declaration
public TimeStamp ToDayFloor()
Returns
Type Description
TimeStamp
| Improve this Doc View Source

ToDayFloor(TimeZoneInfo)

Rounds the given timestamp down to the start of the day for a clock in the given timeZone. If the current timestamp is already at the exact start of the day, a copy of the same timestamp is returned. Compute intensive. Do not use in a hot path.

Declaration
public TimeStamp ToDayFloor(TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeZoneInfo timeZone
Returns
Type Description
TimeStamp

A TimeStamp representing the calculated moment in time.

| Improve this Doc View Source

ToHourCeiling()

Rounds the given timestamp up to the start of the next hour, in absolute time. If the timestamp is at an exact hour, it returns a copy of the same timestamp. Time zone is completely ignored.

Declaration
public TimeStamp ToHourCeiling()
Returns
Type Description
TimeStamp
| Improve this Doc View Source

ToHourCeiling(TimeZoneInfo)

Rounds the given timestamp up to the start of the hour for a clock in the given timeZone. If the current timestamp is already at the exact start of the hour, a copy of the same timestamp is returned. Compute intensive. Do not use in a hot path.

Declaration
public TimeStamp ToHourCeiling(TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeZoneInfo timeZone
Returns
Type Description
TimeStamp

A TimeStamp representing the calculated moment in time.

| Improve this Doc View Source

ToHourFloor()

Rounds the given timestamp down to the start of the hour, in absolute time. If the timestamp is at an exact hour, it returns a copy of the same timestamp. Time zone is completely ignored.

Declaration
public TimeStamp ToHourFloor()
Returns
Type Description
TimeStamp
| Improve this Doc View Source

ToHourFloor(TimeZoneInfo)

Rounds the given timestamp down to the start of the hour for a clock in the given timeZone. If the current timestamp is already at the exact start of the hour, a copy of the same timestamp is returned. Compute intensive. Do not use in a hot path.

Declaration
public TimeStamp ToHourFloor(TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeZoneInfo timeZone
Returns
Type Description
TimeStamp

A TimeStamp representing the calculated moment in time.

| Improve this Doc View Source

ToIntervalCeiling(TimeStamp, TimeSpan)

Divides time from intervalStart into evenly-sized periods (intervals) of length intervalLength and returns the beginning of the next interval to start after the current time. If the time is at an exact interval start, the same value is returned.

Declaration
public TimeStamp ToIntervalCeiling(TimeStamp intervalStart, TimeSpan intervalLength)
Parameters
Type Name Description
TimeStamp intervalStart
TimeSpan intervalLength
Returns
Type Description
TimeStamp
Remarks

You will get unexpected results if the current time is less than intervalStart or if intervalLength is less than or equal to zero.

| Improve this Doc View Source

ToIntervalCeiling(TimeStamp, TimeSpan, TimeZoneInfo)

Divides time from intervalStart into evenly-sized periods (intervals) of length intervalLength and returns the beginning of the next interval to start after the current time. Daylight savings adjustments for the given timeZone are respected. If the time is at an exact interval start, the same value is returned. Compute intensive. Do not use in a hot path.

Declaration
public TimeStamp ToIntervalCeiling(TimeStamp intervalStart, TimeSpan intervalLength, TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeStamp intervalStart
TimeSpan intervalLength
TimeZoneInfo timeZone
Returns
Type Description
TimeStamp
Remarks

You will get unexpected results if the current time is less than intervalStart or if intervalLength is less than or equal to zero.

| Improve this Doc View Source

ToIntervalFloor(TimeStamp, TimeSpan)

Divides time from intervalStart into evenly-sized periods (intervals) of length intervalLength and returns the beginning of the interval in progress. If the time is at an exact interval start, the same value is returned.

Declaration
public TimeStamp ToIntervalFloor(TimeStamp intervalStart, TimeSpan intervalLength)
Parameters
Type Name Description
TimeStamp intervalStart
TimeSpan intervalLength
Returns
Type Description
TimeStamp
Remarks

You will get unexpected results if the current time is less than intervalStart or if intervalLength is less than or equal to zero.

| Improve this Doc View Source

ToIntervalFloor(TimeStamp, TimeSpan, TimeZoneInfo)

Divides time from intervalStart into evenly-sized periods (intervals) of length intervalLength and returns the beginning of the interval in progress. Daylight savings adjustments for the given timeZone are respected. If the time is at an exact interval start, the same value is returned. Compute intensive. Do not use in a hot path.

Declaration
public TimeStamp ToIntervalFloor(TimeStamp intervalStart, TimeSpan intervalLength, TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeStamp intervalStart
TimeSpan intervalLength
TimeZoneInfo timeZone
Returns
Type Description
TimeStamp
Remarks

You will get unexpected results if the current time is less than intervalStart or if intervalLength is less than or equal to zero.

| Improve this Doc View Source

ToIntervalIndex(TimeStamp, TimeSpan)

Divides time from intervalStart into evenly-sized periods (intervals) of length intervalLength Calculates the zero-based index of the interval in progress.

Declaration
public int ToIntervalIndex(TimeStamp intervalStart, TimeSpan intervalLength)
Parameters
Type Name Description
TimeStamp intervalStart
TimeSpan intervalLength
Returns
Type Description
System.Int32
Remarks

You will get unexpected results if the current time is less than intervalStart or if intervalLength is less than or equal to zero.

| Improve this Doc View Source

ToIntervalIndex(TimeStamp, TimeSpan, TimeZoneInfo)

Divides time from intervalStart into evenly-sized periods (intervals) of length intervalLength Calculates the zero-based index of the interval in progress. Daylight savings adjustments for the given timeZone are respected. Compute intensive. Do not use in a hot path.

Declaration
public int ToIntervalIndex(TimeStamp intervalStart, TimeSpan intervalLength, TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeStamp intervalStart
TimeSpan intervalLength
TimeZoneInfo timeZone
Returns
Type Description
System.Int32
Remarks

You will get unexpected results if the current time is less than intervalStart or if intervalLength is less than or equal to zero.

| Improve this Doc View Source

ToLocalString(String)

Creates a string representation of the local time using the given format. Compute intensive. Don't use it in a hot path.

Declaration
public string ToLocalString(string format)
Parameters
Type Name Description
System.String format

The format string.

Returns
Type Description
System.String
| Improve this Doc View Source

ToMillisecondCeiling()

Rounds the given timestamp up to the start of the next millisecond, in absolute time. If the timestamp is at an exact millisecond, it returns a copy of the same timestamp.

Declaration
public TimeStamp ToMillisecondCeiling()
Returns
Type Description
TimeStamp
| Improve this Doc View Source

ToMillisecondFloor()

Rounds the given timestamp down to the start of the millisecond, in absolute time. If the timestamp is at an exact millisecond, it returns a copy of the same timestamp.

Declaration
public TimeStamp ToMillisecondFloor()
Returns
Type Description
TimeStamp
| Improve this Doc View Source

ToMinuteCeiling()

Rounds the given timestamp up to the start of the next minute, in absolute time. If the timestamp is at an exact minute, it returns a copy of the same timestamp. Time zone is completely ignored.

Declaration
public TimeStamp ToMinuteCeiling()
Returns
Type Description
TimeStamp
| Improve this Doc View Source

ToMinuteFloor()

Rounds the given timestamp down to the start of the minute, in absolute time. If the timestamp is at an exact minute, it returns a copy of the same timestamp. Time zone is completely ignored.

Declaration
public TimeStamp ToMinuteFloor()
Returns
Type Description
TimeStamp
| Improve this Doc View Source

ToMinuteOfDayIndex()

Returns zero-based index of the current minute within the day in the utc timezone. Values returned range from 0 to 1440 - 1.

Declaration
public int ToMinuteOfDayIndex()
Returns
Type Description
System.Int32
| Improve this Doc View Source

ToMinuteOfDayIndex(TimeZoneInfo)

Returns zero-based index of the current minute within the day in the given timeZone. Values returned range from 0 to 1440 - 1. Compute intensive. Do not use in hot path.

Declaration
public int ToMinuteOfDayIndex(TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeZoneInfo timeZone
Returns
Type Description
System.Int32
| Improve this Doc View Source

ToMinuteOfWeekIndex()

Returns zero-based index of the current minute within the week in the utc timezone. Values returned range from 0 to 7 * 1440 - 1. The zero point is midnight, Sunday.

Declaration
public int ToMinuteOfWeekIndex()
Returns
Type Description
System.Int32
| Improve this Doc View Source

ToMinuteOfWeekIndex(TimeZoneInfo)

Returns zero-based index of the current minute within the week in the given timeZone. Values returned range from 0 to 7 * 1440 - 1. The zero point is midnight, Sunday. Compute intensive. Do not use in hot path.

Declaration
public int ToMinuteOfWeekIndex(TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeZoneInfo timeZone
Returns
Type Description
System.Int32
| Improve this Doc View Source

ToMonthCeiling(TimeZoneInfo)

Rounds the given timestamp up to the start of the month for a clock in the given timeZone. If the current timestamp is already at the exact start of the month, a copy of the same timestamp is returned. Start of the month is considered to be midnight of the first day of the month. Compute intensive. Do not use in a hot path.

Declaration
public TimeStamp ToMonthCeiling(TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeZoneInfo timeZone
Returns
Type Description
TimeStamp

A TimeStamp representing the calculated moment in time.

| Improve this Doc View Source

ToMonthFloor(TimeZoneInfo)

Rounds the given timestamp down to the start of the month for a clock in the given timeZone. If the current timestamp is already at the exact start of the month, a copy of the same timestamp is returned. Start of the month is considered to be midnight of the first day of the month. Compute intensive. Do not use in a hot path.

Declaration
public TimeStamp ToMonthFloor(TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeZoneInfo timeZone
Returns
Type Description
TimeStamp

A TimeStamp representing the calculated moment in time.

| Improve this Doc View Source

ToPeriodOfWeekCeiling(TimeSpan, TimeSpan, TimeZoneInfo)

Divides the week into periods of length periodLength, and then calculates the beginning of the period after the period active at the current time. Beginning of the first period is considered to be midnight, Sunday. Periods include the first tick (index == 0) and exclude the the first tick of the next period (index < periodLengthInMinutes * TimeSpan.TicksPerMinute) If the current time is at an exact period start, the same value is returned Daylight savings adjustments for the given timeZone are respected. Compute intensive. Do not use in a hot path.

Declaration
public TimeStamp ToPeriodOfWeekCeiling(TimeSpan periodLength, TimeSpan periodOffset, TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeSpan periodLength
TimeSpan periodOffset
TimeZoneInfo timeZone
Returns
Type Description
TimeStamp
| Improve this Doc View Source

ToPeriodOfWeekCeiling(TimeSpan, TimeZoneInfo)

Divides the week into periods of length periodLength, and then calculates the beginning of the period after the period active at the current time. Beginning of the first period is considered to be midnight, Sunday. Periods include the first tick (index == 0) and exclude the the first tick of the next period (index < periodLengthInMinutes * TimeSpan.TicksPerMinute) If the current time is at an exact period start, the same value is returned.

Declaration
public TimeStamp ToPeriodOfWeekCeiling(TimeSpan periodLength, TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeSpan periodLength
TimeZoneInfo timeZone
Returns
Type Description
TimeStamp
| Improve this Doc View Source

ToPeriodOfWeekFloor(TimeSpan, TimeSpan, TimeZoneInfo)

Divides the week into periods of length periodLength, and then calculates the beginning of the period active at the current time. Beginning of the first period is considered to be midnight, Sunday. Periods include the first tick (index == 0) and exclude the the first tick of the next period (index < periodLengthInMinutes * TimeSpan.TicksPerMinute) If the current time is at an exact period start, the same value is returned. Daylight savings adjustments for the given timeZone are respected. Compute intensive. Do not use in a hot path.

Declaration
public TimeStamp ToPeriodOfWeekFloor(TimeSpan periodLength, TimeSpan periodOffset, TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeSpan periodLength
TimeSpan periodOffset
TimeZoneInfo timeZone
Returns
Type Description
TimeStamp
| Improve this Doc View Source

ToPeriodOfWeekFloor(TimeSpan, TimeZoneInfo)

Divides the week into periods of length periodLength, and then calculates the beginning of the period active at the current time. Beginning of the first period is considered to be midnight, Sunday. Periods include the first tick (index == 0) and exclude the the first tick of the next period (index < periodLengthInMinutes * TimeSpan.TicksPerMinute) If the current time is at an exact period start, the same value is returned.

Declaration
public TimeStamp ToPeriodOfWeekFloor(TimeSpan periodLength, TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeSpan periodLength
TimeZoneInfo timeZone
Returns
Type Description
TimeStamp
| Improve this Doc View Source

ToPeriodOfWeekIndex(TimeSpan, TimeSpan, TimeZoneInfo)

Divides the week into periods of length periodLength, and then calculates the zero-based index of the period at the current time. Beginning of the first period is considered to be midnight, Sunday. Periods include the first tick (index == 0) and exclude the the first tick of the next period (index < periodLength) Daylight savings adjustments for the given timeZone are respected. Compute intensive. Do not use in a hot path.

Declaration
public int ToPeriodOfWeekIndex(TimeSpan periodLength, TimeSpan periodOffset, TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeSpan periodLength
TimeSpan periodOffset
TimeZoneInfo timeZone
Returns
Type Description
System.Int32
| Improve this Doc View Source

ToPeriodOfWeekIndex(TimeSpan, TimeZoneInfo)

Divides the week into periods of length periodLength, and then calculates the zero-based index of the period at the current time. Beginning of the first period is considered to be midnight, Sunday. Periods include the first tick (index == 0) and exclude the the first tick of the next period (index < periodLength).

Declaration
public int ToPeriodOfWeekIndex(TimeSpan periodLength, TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeSpan periodLength
TimeZoneInfo timeZone
Returns
Type Description
System.Int32
| Improve this Doc View Source

ToSecondCeiling()

Rounds the given timestamp up to the start of the next second, in absolute time. If the timestamp is at an exact second, it returns a copy of the same timestamp. Time zone is completely ignored.

Declaration
public TimeStamp ToSecondCeiling()
Returns
Type Description
TimeStamp
| Improve this Doc View Source

ToSecondFloor()

Rounds the given timestamp down to the start of the second, in absolute time. If the timestamp is at an exact second, it returns a copy of the same timestamp. Time zone is completely ignored.

Declaration
public TimeStamp ToSecondFloor()
Returns
Type Description
TimeStamp
| Improve this Doc View Source

ToSecondOfDayIndex()

Returns zero-based index of the current second within the day in the utc timezone. Values returned range from 0 to 1440 * 60 - 1.

Declaration
public int ToSecondOfDayIndex()
Returns
Type Description
System.Int32
| Improve this Doc View Source

ToSecondOfDayIndex(TimeZoneInfo)

Returns zero-based index of the current second within the day in the given timeZone. Values returned range from 0 to 1440 * 60 - 1 Compute intensive. Do not use in hot path.

Declaration
public int ToSecondOfDayIndex(TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeZoneInfo timeZone
Returns
Type Description
System.Int32
| Improve this Doc View Source

ToSecondOfWeekIndex()

Returns zero-based index of the current second within the week in the utc timezone. Values returned range from 0 to 7 * 1440 * 60 - 1. The zero point is midnight, Sunday.

Declaration
public int ToSecondOfWeekIndex()
Returns
Type Description
System.Int32
| Improve this Doc View Source

ToSecondOfWeekIndex(TimeZoneInfo)

Returns zero-based index of the current second within the week in the given timeZone. Values returned range from 0 to 7 * 1440 * 60 - 1. The zero point is midnight, Sunday. Compute intensive. Do not use in hot path.

Declaration
public int ToSecondOfWeekIndex(TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeZoneInfo timeZone
Returns
Type Description
System.Int32
| Improve this Doc View Source

ToString()

Creates a string representation of the utc time using the default format.

Declaration
public override string ToString()
Returns
Type Description
System.String
| Improve this Doc View Source

ToString(String)

Creates a string representation of the utc time using the given format.

Declaration
public string ToString(string format)
Parameters
Type Name Description
System.String format

The format string.

Returns
Type Description
System.String
| Improve this Doc View Source

ToString(TimeZoneInfo)

Creates a string representation of the timeZone time with default formatting. Compute intensive. Don't use it in a hot path.

Declaration
public string ToString(TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeZoneInfo timeZone

The time zone to be used for expressing this value as a time string.

Returns
Type Description
System.String
| Improve this Doc View Source

ToString(TimeZoneInfo, String)

Creates a string representation of the timeZone time using the given format. Compute intensive. Don't use it in a hot path.

Declaration
public string ToString(TimeZoneInfo timeZone, string format)
Parameters
Type Name Description
TimeZoneInfo timeZone

The time zone to be used for expressing this value as a time string.

System.String format

The format string.

Returns
Type Description
System.String
| Improve this Doc View Source

ToTimeOfDay()

Gets the time of day in the utc timezone.

Declaration
public TimeSpan ToTimeOfDay()
Returns
Type Description
TimeSpan
| Improve this Doc View Source

ToTimeOfDay(TimeZoneInfo)

Gets the time of day in the given timeZone. Compute intensive. Do not use in a hot path.

Declaration
public TimeSpan ToTimeOfDay(TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeZoneInfo timeZone
Returns
Type Description
TimeSpan
| Improve this Doc View Source

ToUnixMillieconds()

Gets the number of milliseconds since Midnight, 1 January 1970, UTC.

Declaration
public long ToUnixMillieconds()
Returns
Type Description
System.Int64
| Improve this Doc View Source

ToUnixMilliseconds(TimeZoneInfo)

Gets the number of milliseconds since Midnight, 1 January 1970, in the given timeZone Compute intensive. Do not use in a hot path.

Declaration
public long ToUnixMilliseconds(TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeZoneInfo timeZone
Returns
Type Description
System.Int64
| Improve this Doc View Source

ToUnixSeconds()

Gets the number of seconds since Midnight, 1 January 1970, UTC.

Declaration
public long ToUnixSeconds()
Returns
Type Description
System.Int64
| Improve this Doc View Source

ToUnixSeconds(TimeZoneInfo)

Gets the number of seconds since Midnight, 1 January 1970, in the given timeZone Compute intensive. Do not use in a hot path.

Declaration
public long ToUnixSeconds(TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeZoneInfo timeZone
Returns
Type Description
System.Int64
| Improve this Doc View Source

ToWeekCeiling()

Rounds the given timestamp up to the start of the next week, in absolute time. If the timestamp is at an exact week, it returns a copy of the same timestamp. Time zone is completely ignored. Week ceiling is considered to be midnight, Sunday.

Declaration
public TimeStamp ToWeekCeiling()
Returns
Type Description
TimeStamp
| Improve this Doc View Source

ToWeekCeiling(TimeZoneInfo)

Rounds the given timestamp up to the start of the week for a clock in the given timeZone. If the current timestamp is already at the exact start of the week, a copy of the same timestamp is returned. Start of the week is considered to be midnight, Sunday. Compute intensive. Do not use in a hot path.

Declaration
public TimeStamp ToWeekCeiling(TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeZoneInfo timeZone
Returns
Type Description
TimeStamp

A TimeStamp representing the calculated moment in time.

| Improve this Doc View Source

ToWeekFloor()

Rounds the given timestamp down to the start of the day, in absolute time. If the timestamp is at an exact day, it returns a copy of the same timestamp. Time zone is completely ignored. Week floor is considered to be midnight, Sunday.

Declaration
public TimeStamp ToWeekFloor()
Returns
Type Description
TimeStamp
| Improve this Doc View Source

ToWeekFloor(TimeZoneInfo)

Rounds the given timestamp down to the start of the week for a clock in the given timeZone. If the current timestamp is already at the exact start of the week, a copy of the same timestamp is returned. Start of the week is considered to be midnight, Sunday. Compute intensive. Do not use in a hot path.

Declaration
public TimeStamp ToWeekFloor(TimeZoneInfo timeZone)
Parameters
Type Name Description
TimeZoneInfo timeZone
Returns
Type Description
TimeStamp

A TimeStamp representing the calculated moment in time.

Operators

| Improve this Doc View Source

Addition(TimeStamp, Int64)

Declaration
public static TimeStamp operator +(TimeStamp a, in long ticks)
Parameters
Type Name Description
TimeStamp a
System.Int64 ticks
Returns
Type Description
TimeStamp
| Improve this Doc View Source

Addition(TimeStamp, TimeSpan)

Declaration
public static TimeStamp operator +(TimeStamp a, TimeSpan time)
Parameters
Type Name Description
TimeStamp a
TimeSpan time
Returns
Type Description
TimeStamp
| Improve this Doc View Source

Equality(TimeStamp, TimeStamp)

Declaration
public static bool operator ==(TimeStamp a, TimeStamp b)
Parameters
Type Name Description
TimeStamp a
TimeStamp b
Returns
Type Description
System.Boolean
| Improve this Doc View Source

GreaterThan(TimeStamp, TimeStamp)

Declaration
public static bool operator>(TimeStamp a, TimeStamp b)
Parameters
Type Name Description
TimeStamp a
TimeStamp b
Returns
Type Description
System.Boolean
| Improve this Doc View Source

GreaterThanOrEqual(TimeStamp, TimeStamp)

Declaration
public static bool operator >=(TimeStamp a, TimeStamp b)
Parameters
Type Name Description
TimeStamp a
TimeStamp b
Returns
Type Description
System.Boolean
| Improve this Doc View Source

Implicit(TimeStamp to Int64)

Declaration
public static implicit operator long (TimeStamp a)
Parameters
Type Name Description
TimeStamp a
Returns
Type Description
System.Int64
| Improve this Doc View Source

Implicit(Int64 to TimeStamp)

Declaration
public static implicit operator TimeStamp(long ticksUtc)
Parameters
Type Name Description
System.Int64 ticksUtc
Returns
Type Description
TimeStamp
| Improve this Doc View Source

Inequality(TimeStamp, TimeStamp)

Declaration
public static bool operator !=(TimeStamp a, TimeStamp b)
Parameters
Type Name Description
TimeStamp a
TimeStamp b
Returns
Type Description
System.Boolean
| Improve this Doc View Source

LessThan(TimeStamp, TimeStamp)

Declaration
public static bool operator <(TimeStamp a, TimeStamp b)
Parameters
Type Name Description
TimeStamp a
TimeStamp b
Returns
Type Description
System.Boolean
| Improve this Doc View Source

LessThanOrEqual(TimeStamp, TimeStamp)

Declaration
public static bool operator <=(TimeStamp a, TimeStamp b)
Parameters
Type Name Description
TimeStamp a
TimeStamp b
Returns
Type Description
System.Boolean
| Improve this Doc View Source

Subtraction(TimeStamp, TimeStamp)

Declaration
public static TimeSpan operator -(TimeStamp a, TimeStamp b)
Parameters
Type Name Description
TimeStamp a
TimeStamp b
Returns
Type Description
TimeSpan
| Improve this Doc View Source

Subtraction(TimeStamp, Int64)

Declaration
public static TimeStamp operator -(TimeStamp a, in long ticks)
Parameters
Type Name Description
TimeStamp a
System.Int64 ticks
Returns
Type Description
TimeStamp
| Improve this Doc View Source

Subtraction(TimeStamp, TimeSpan)

Declaration
public static TimeStamp operator -(TimeStamp a, TimeSpan time)
Parameters
Type Name Description
TimeStamp a
TimeSpan time
Returns
Type Description
TimeStamp

Implements

IComparable<>
IEquatable<>
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX