Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

struct NodaTime.​HighPerformance.​Instant64

Assembly: NodaTime

Implemented Interfaces

Represents an instant on the global timeline, with nanosecond resolution. This type is a equivalent to <see cref="T:NodaTime.Instant" /> , but with a more limited range (a few hundred years either side of the Unix epoch) and more compact, high performance representation. It is expected to be used in conjunction with <see cref="T:NodaTime.HighPerformance.Duration64" /> , typically in scenarios where performance and/or memory usage are important. Note that in most cases, <see cref="T:NodaTime.Instant" /> is more appropriate and convenient (with more supported methods etc). This should effectively be regarded as a specialist type for unusually performance-sensitive scenarios.

Remarks

<para> An <see cref="T:NodaTime.HighPerformance.Instant64" /> has no concept of a particular time zone or calendar: it simply represents a point in time that can be globally agreed-upon. </para> <para> Equality and ordering comparisons are defined in the natural way, with earlier points on the timeline being considered "less than" later points. </para> <para>The default value of this type is <see cref="P:NodaTime.HighPerformance.Instant64.UnixEpoch" />, i.e. the instant which can be represented as 1970-01-01T00:00:00Z in the ISO calendar.</para>

Properties

public static Instant64
UnixEpoch
The instant at the Unix epoch of midnight 1st January 1970 UTC.
public static Instant64
MinValue
Represents the smallest possible <see cref="T:NodaTime.HighPerformance.Instant64" /> .
Remarks This value is equivalent to 1677-09-21T00:12:43.145224192Z.
public static Instant64
MaxValue
Represents the largest possible <see cref="T:NodaTime.HighPerformance.Instant64" /> .
Remarks This value is equivalent to 2262-04-11T23:47:16.854775807Z.

Methods

public int
CompareTo​(Instant64 other)
Compares the current object with another object of the same type. See the type documentation for a description of ordering semantics.
Returns A 32-bit signed integer that indicates the relative order of the objects being compared. The return value has the following meanings: <list type="table"> <listheader> <term>Value</term> <description>Meaning</description> </listheader> <item> <term>&lt; 0</term> <description>This object is less than the <paramref name="other" /> parameter.</description> </item> <item> <term>0</term> <description>This object is equal to <paramref name="other" />.</description> </item> <item> <term>&gt; 0</term> <description>This object is greater than <paramref name="other" />.</description> </item> </list>
other An object to compare with this object.
public bool
Equals​(object obj)
Determines whether the specified <see cref="T:System.Object" /> is equal to this instance. See the type documentation for a description of equality semantics.
Returns <c>true</c> if the specified <see cref="T:System.Object" /> is equal to this instance; otherwise, <c>false</c> .
obj The <see cref="T:System.Object" /> to compare with this instance.
public int
GetHashCode​()
Returns a hash code for this instance. See the type documentation for a description of equality semantics.
Returns A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
public Instant64
PlusTicks​(long ticks)
Returns a new value of this instant with the given number of ticks added to it.
Returns The result of adding the given number of ticks to this instant.
ticks The ticks to add to this instant to create the return value.
public Instant64
PlusNanoseconds​(long nanoseconds)
Returns a new value of this instant with the given number of nanoseconds added to it.
Returns The result of adding the given number of ticks to this instant.
nanoseconds The nanoseconds to add to this instant to create the return value.
public static Instant64
Add​(Instant64 left, Duration64 right)
Adds a duration to an instant. Friendly alternative to <c>operator+()</c> .
Returns A new <see cref="T:NodaTime.HighPerformance.Instant64" /> representing the sum of the given values.
left The left hand side of the operator.
right The right hand side of the operator.
public Instant64
Plus​(Duration64 duration)
Returns the result of adding a duration to this instant, for a fluent alternative to <c>operator+()</c> .
Returns A new <see cref="T:NodaTime.HighPerformance.Instant64" /> representing the result of the addition.
duration The duration to add
public static Duration64
Subtract​(Instant64 left, Instant64 right)
Subtracts one instant from another. Friendly alternative to <c>operator-()</c> .
Returns A new <see cref="T:NodaTime.HighPerformance.Duration64" /> representing the difference of the given values.
left The left hand side of the operator.
right The right hand side of the operator.
public Duration64
Minus​(Instant64 other)
Returns the result of subtracting another instant from this one, for a fluent alternative to <c>operator-()</c> .
Returns A new <see cref="T:NodaTime.HighPerformance.Instant64" /> representing the result of the subtraction.
other The other instant to subtract
public static Instant64
Subtract​(Instant64 left, Duration64 right)
Subtracts a duration from an instant. Friendly alternative to <c>operator-()</c> .
Returns A new <see cref="T:NodaTime.HighPerformance.Instant64" /> representing the difference of the given values.
left The left hand side of the operator.
right The right hand side of the operator.
public Instant64
Minus​(Duration64 duration)
Returns the result of subtracting a duration from this instant, for a fluent alternative to <c>operator-()</c> .
Returns A new <see cref="T:NodaTime.HighPerformance.Instant64" /> representing the result of the subtraction.
duration The duration to subtract
public static Instant64
FromUtc​(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour)
Returns a new instant corresponding to the given UTC date and time in the ISO calendar.
Returns An <see cref="T:NodaTime.HighPerformance.Instant64" /> value representing the given date and time in UTC and the ISO calendar.
year The year. This is the "absolute year", so a value of 0 means 1 BC, for example.
monthOfYear The month of year.
dayOfMonth The day of month.
hourOfDay The hour.
minuteOfHour The minute.
public static Instant64
FromUtc​(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute)
Returns a new instant corresponding to the given UTC date and time in the ISO calendar.
Returns An <see cref="T:NodaTime.HighPerformance.Instant64" /> value representing the given date and time in UTC and the ISO calendar.
year The year. This is the "absolute year", so a value of 0 means 1 BC, for example.
monthOfYear The month of year.
dayOfMonth The day of month.
hourOfDay The hour.
minuteOfHour The minute.
secondOfMinute The second.
public static Instant64
Max​(Instant64 x, Instant64 y)
Returns the later instant of the given two.
Returns The later instant of <paramref name="x" /> or <paramref name="y" /> .
x The first instant to compare.
y The second instant to compare.
public static Instant64
Min​(Instant64 x, Instant64 y)
Returns the earlier instant of the given two.
Returns The earlier instant of <paramref name="x" /> or <paramref name="y" /> .
x The first instant to compare.
y The second instant to compare.
public string
ToString​()
Returns a <see cref="T:System.String" /> that represents this instance.
Returns The value of the current instance, converted to an <see cref="T:NodaTime.Instant" /> , in the default format pattern ("g"), using the current thread's culture to obtain a format provider.
public string
ToString​(string patternText, System.​IFormatProvider formatProvider)
Formats the value of the current instance, converted to an <see cref="T:NodaTime.Instant" /> , using the specified pattern.
Returns A <see cref="T:System.String" /> containing the value of the current instance in the specified format.
patternText The <see cref="T:System.String" /> specifying the pattern to use, or null to use the default format pattern ("g").
formatProvider The <see cref="T:System.IFormatProvider" /> to use when formatting the value, or null to use the current thread's culture to obtain a format provider.
public bool
Equals​(Instant64 other)
Indicates whether the value of this instant is equal to the value of the specified instant. See the type documentation for a description of equality semantics.
Returns true if the value of this instant is equal to the value of the <paramref name="other" /> parameter; otherwise, false.
other The value to compare with this instance.
ToDateTimeUtc​()
Constructs a <see cref="T:System.DateTime" /> from this instant which has a <see cref="P:System.DateTime.Kind" /> of <see cref="F:System.DateTimeKind.Utc" /> and represents the same instant of time as this value.
Returns A <see cref="T:System.DateTime" /> representing the same instant in time as this value, with a kind of "universal".
Remarks <para> If the date and time is not on a tick boundary (the unit of granularity of DateTime) the value will be truncated towards the start of time. Note that this means the result of calling this method on <see cref="P:NodaTime.HighPerformance.Instant64.MinValue" /> is a value which is out of range for <see cref="M:NodaTime.HighPerformance.Instant64.FromDateTimeUtc(System.DateTime)" />. </para>
ToDateTimeOffset​()
Constructs a <see cref="T:System.DateTimeOffset" /> from this instant which has an offset of zero.
Returns A <see cref="T:System.DateTimeOffset" /> representing the same instant in time as this value.
Remarks <para> If the date and time is not on a tick boundary (the unit of granularity of DateTime) the value will be truncated towards the start of time. Note that this means the result of calling this method on <see cref="P:NodaTime.HighPerformance.Instant64.MinValue" /> is a value which is out of range for <see cref="M:NodaTime.HighPerformance.Instant64.FromDateTimeOffset(System.DateTimeOffset)" />. </para>
public static Instant64
FromDateTimeOffset​(System.​DateTimeOffset dateTimeOffset)
Converts a <see cref="T:System.DateTimeOffset" /> into a new instant representing the same instant in time. Note that the offset information is not preserved in the returned instant.
Returns An <see cref="T:NodaTime.HighPerformance.Instant64" /> value representing the same instant in time as the given <see cref="T:System.DateTimeOffset" /> .
dateTimeOffset Date and time value with an offset.
public static Instant64
FromDateTimeUtc​(System.​DateTime dateTime)
Converts a <see cref="T:System.DateTime" /> into a new instant representing the same instant in time.
Returns An <see cref="T:NodaTime.HighPerformance.Instant64" /> value representing the same instant in time as the given universal <see cref="T:System.DateTime" /> .
dateTime Date and time value which must have a <see cref="P:System.DateTime.Kind" /> of <see cref="F:System.DateTimeKind.Utc" />
public static Instant64
FromUnixTimeSeconds​(long seconds)
Initializes a new instance of the <see cref="T:NodaTime.HighPerformance.Instant64" /> struct based on a number of seconds since the Unix epoch of (ISO) January 1st 1970, midnight, UTC.
Returns An <see cref="T:NodaTime.HighPerformance.Instant64" /> at exactly the given number of seconds since the Unix epoch.
seconds Number of seconds since the Unix epoch. May be negative (for instants before the epoch).
public static Instant64
FromUnixTimeMilliseconds​(long milliseconds)
Initializes a new instance of the <see cref="T:NodaTime.HighPerformance.Instant64" /> struct based on a number of milliseconds since the Unix epoch of (ISO) January 1st 1970, midnight, UTC.
Returns An <see cref="T:NodaTime.HighPerformance.Instant64" /> at exactly the given number of milliseconds since the Unix epoch.
milliseconds Number of milliseconds since the Unix epoch. May be negative (for instants before the epoch).
public static Instant64
FromUnixTimeTicks​(long ticks)
Initializes a new instance of the <see cref="T:NodaTime.HighPerformance.Instant64" /> struct based on a number of ticks since the Unix epoch of (ISO) January 1st 1970, midnight, UTC.
Returns An <see cref="T:NodaTime.HighPerformance.Instant64" /> at exactly the given number of ticks since the Unix epoch.
ticks Number of ticks since the Unix epoch. May be negative (for instants before the epoch).
public static Instant64
FromUnixTimeNanoseconds​(long nanoseconds)
Initializes a new instance of the <see cref="T:NodaTime.HighPerformance.Instant64" /> struct based on a number of nanoseconds since the Unix epoch of (ISO) January 1st 1970, midnight, UTC.
Returns An <see cref="T:NodaTime.HighPerformance.Instant64" /> at exactly the given number of seconds since the Unix epoch.
nanoseconds Number of nanoseconds since the Unix epoch. May be negative (for instants before the epoch).
public long
ToUnixTimeSeconds​()
Gets the number of seconds since the Unix epoch. Negative values represent instants before the Unix epoch.
Remarks If the number of nanoseconds in this instant is not an exact number of seconds, the value is truncated towards the start of time.
public System.​ValueTuple<​long, int>
ToUnixTimeSecondsAndNanoseconds​()
Gets the number of seconds since the Unix epoch, along with remaining nanoseconds. Negative values for seconds represent instants before the Unix epoch.
Remarks <para> If the number of nanoseconds in this instant is not an exact number of seconds the seconds part of the returned value is truncated towards the start of time, ensuring that the nanoseconds part is always non-negative. The seconds part of the returned value is always the same as would be returned by <see cref="M:NodaTime.HighPerformance.Instant64.ToUnixTimeSeconds" />. </para> <para> The inverse of this operation is to first call <see cref="M:NodaTime.HighPerformance.Instant64.FromUnixTimeSeconds(System.Int64)" /> and then call <see cref="M:NodaTime.HighPerformance.Instant64.PlusNanoseconds(System.Int64)" /> on the returned <see cref="T:NodaTime.HighPerformance.Instant64" />. </para>
public long
ToUnixTimeMilliseconds​()
Gets the number of milliseconds since the Unix epoch. Negative values represent instants before the Unix epoch.
Remarks If the number of nanoseconds in this instant is not an exact number of milliseconds, the value is truncated towards the start of time.
public long
ToUnixTimeTicks​()
Gets the number of ticks since the Unix epoch. Negative values represent instants before the Unix epoch.
Returns The number of ticks since the Unix epoch.
Remarks A tick is equal to 100 nanoseconds. There are 10,000 ticks in a millisecond. If the number of nanoseconds in this instant is not an exact number of ticks, the value is truncated towards the start of time.
public long
ToUnixTimeNanoseconds​()
Gets the number of nanoseconds since the Unix epoch. Negative values represent instants before the Unix epoch.
Returns The number of ticks since the Unix epoch.
public Instant
ToInstant​()
Converts this value to an <see cref="T:NodaTime.Instant" /> representing the same instant in time. This operation always succeeds and loses no information.
Returns An <see cref="T:NodaTime.Instant" /> representing the same instant in time as this one.
public static Instant64
FromInstant​(Instant instant)
Creates an <see cref="T:NodaTime.HighPerformance.Instant64" /> value representing the same instant in time as the specified <see cref="T:NodaTime.Instant" /> . When this succeeds, this conversion loses no information. If the specified value is outside the range of <see cref="T:NodaTime.HighPerformance.Instant64" /> , this method will fail with an <see cref="T:System.OverflowException" /> .
Returns An <see cref="T:NodaTime.HighPerformance.Instant64" /> value equivalent to <paramref name="instant" /> .
instant The value to convert to a <see cref="T:NodaTime.HighPerformance.Instant64" /> .
protected void
Finalize​()
Inherited from object
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object