Table of Contents

Struct TimestampTag

Namespace
Discord
Assembly
Discord.Net.Core.dll

Represents a class used to make timestamps in messages. see https://discord.com/developers/docs/reference#message-formatting-timestamp-styles.

public readonly struct TimestampTag
Inherited Members

Constructors

TimestampTag(DateTimeOffset, TimestampTagStyles?)

Creates a new TimestampTag from the provided time.

public TimestampTag(DateTimeOffset time, TimestampTagStyles? style = null)

Parameters

time DateTimeOffset

The time for this timestamp tag.

style TimestampTagStyles?

The style for this timestamp tag.

Properties

Style

Gets the style of this tag. null if none was provided.

public TimestampTagStyles? Style { get; }

Property Value

TimestampTagStyles?

Time

Gets the time for this timestamp tag.

public DateTimeOffset Time { get; }

Property Value

DateTimeOffset

Methods

FormatFromDateTime(DateTime, TimestampTagStyles)

Immediately formats the provided time and style into a timestamp string.

public static string FormatFromDateTime(DateTime time, TimestampTagStyles style)

Parameters

time DateTime

The time of this timestamp tag.

style TimestampTagStyles

The style for this timestamp tag.

Returns

string

The newly create timestamp string.

FormatFromDateTimeOffset(DateTimeOffset, TimestampTagStyles)

Immediately formats the provided time and style into a timestamp string.

public static string FormatFromDateTimeOffset(DateTimeOffset time, TimestampTagStyles style)

Parameters

time DateTimeOffset

The time of this timestamp tag.

style TimestampTagStyles

The style for this timestamp tag.

Returns

string

The newly create timestamp string.

FromDateTime(DateTime, TimestampTagStyles?)

Creates a new timestamp tag with the specified DateTime object.

public static TimestampTag FromDateTime(DateTime time, TimestampTagStyles? style = null)

Parameters

time DateTime

The time of this timestamp tag.

style TimestampTagStyles?

The style for this timestamp tag.

Returns

TimestampTag

The newly create timestamp tag.

FromDateTimeOffset(DateTimeOffset, TimestampTagStyles?)

Creates a new timestamp tag with the specified DateTimeOffset object.

public static TimestampTag FromDateTimeOffset(DateTimeOffset time, TimestampTagStyles? style = null)

Parameters

time DateTimeOffset

The time of this timestamp tag.

style TimestampTagStyles?

The style for this timestamp tag.

Returns

TimestampTag

The newly create timestamp tag.

ToString()

Converts the current timestamp tag to the string representation supported by discord.

If the Time is null then the default 0 will be used.

public override string ToString()

Returns

string

A string that is compatible in a discord message, ex:

<t:1625944201:f>

Remarks

Will use the provided Style if provided. If this value is null, it will default to ShortDateTime.

ToString(TimestampTagStyles)

Converts the current timestamp tag to the string representation supported by discord.

If the Time is null then the default 0 will be used.

public string ToString(TimestampTagStyles style)

Parameters

style TimestampTagStyles

The formatting style for this tag.

Returns

string

A string that is compatible in a discord message, ex:

<t:1625944201:f>