Show / Hide Table of Contents

Class DateTimeExtensions

System.DateTime extension methods.

Inheritance
System.Object
DateTimeExtensions
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: GlitchedPolygons.ExtensionMethods
Assembly: UnityScriptsLibrary.dll
Syntax
public static class DateTimeExtensions

Methods

| Improve this Doc View Source

AlmostEquals(DateTime, DateTime, Double)

Checks whether the given System.DateTime is almost equal to another System.DateTime object.

Declaration
public static bool AlmostEquals(this DateTime dt1, DateTime dt2, double threshold = 1)
Parameters
Type Name Description
System.DateTime dt1

The System.DateTime to compare.

System.DateTime dt2

The System.DateTime to compare.

System.Double threshold

The equality-defining threshold in seconds between the two System.DateTimes. If the two System.DateTimes are further apart from each other than this amount of seconds, they're not equal.

Returns
Type Description
System.Boolean

Whether the two System.DateTime objects are almost equal.

| Improve this Doc View Source

FromUnixTimeMilliseconds(Int64)

Converts a Unix timestamp (milliseconds since 1970-01-01 00:00:00.000 UTC) to a System.DateTime (in UTC).

Declaration
public static DateTime FromUnixTimeMilliseconds(long timestamp)
Parameters
Type Name Description
System.Int64 timestamp

The Unix timestamp to convert.

Returns
Type Description
System.DateTime

The converted System.DateTime in UTC.

| Improve this Doc View Source

FromUnixTimeSeconds(Int64)

Converts a Unix timestamp (seconds since 1970-01-01T00:00:00Z) to a UTC System.DateTime.

Declaration
public static DateTime FromUnixTimeSeconds(long timestamp)
Parameters
Type Name Description
System.Int64 timestamp

The Unix timestamp to convert.

Returns
Type Description
System.DateTime

The converted System.DateTime in UTC.

| Improve this Doc View Source

ToRfc3339String(DateTime)

Converts System.DateTime to a RFC3339 string.

Declaration
public static string ToRfc3339String(this DateTime dateTime)
Parameters
Type Name Description
System.DateTime dateTime

The System.DateTime to stringify.

Returns
Type Description
System.String

The System.DateTime as a RFC3339 string

| Improve this Doc View Source

ToUnixTimeMilliseconds(DateTime)

Converts a System.DateTime to Unix time (milliseconds since 1970-01-01T00:00:00Z).

Make sure that the System.DateTime you're converting is UTC!

Declaration
public static long ToUnixTimeMilliseconds(this DateTime dt)
Parameters
Type Name Description
System.DateTime dt

The System.DateTime to convert.

Returns
Type Description
System.Int64

Unix time (milliseconds since 1970-01-01T00:00:00Z)

| Improve this Doc View Source

ToUnixTimeSeconds(DateTime)

Converts a System.DateTime to Unix time (seconds since 1970-01-01T00:00:00Z).

Make sure that the System.DateTime you're converting is in UTC!

Declaration
public static long ToUnixTimeSeconds(this DateTime dt)
Parameters
Type Name Description
System.DateTime dt

The System.DateTime to convert.

Returns
Type Description
System.Int64

Unix time (seconds since 1970-01-01T00:00:00Z)

  • Improve this Doc
  • View Source
Back to top Generated by DocFX