Browse Source

Im so sad v2

pull/2468/head
Rozen 2 years ago
parent
commit
964fa4ed84
No known key found for this signature in database GPG Key ID: 490AA5E30F4F3BC0
1 changed files with 20 additions and 2 deletions
  1. +20
    -2
      src/Discord.Net.Core/Entities/Messages/TimestampTag.cs

+ 20
- 2
src/Discord.Net.Core/Entities/Messages/TimestampTag.cs View File

@@ -20,8 +20,8 @@ namespace Discord
/// <summary>
/// Creates a new <see cref="TimestampTag"/> from the provided time.
/// </summary>
/// <param name="time">The time for this tag.</param>
/// <param name="style">The style for this tag.</param>
/// <param name="time">The time for this timestamp tag.</param>
/// <param name="style">The style for this timestamp tag.</param>
public TimestampTag(DateTimeOffset time, TimestampTagStyles? style = null)
{
Time = time;
@@ -69,5 +69,23 @@ namespace Discord
/// <returns>The newly create timestamp tag.</returns>
public static TimestampTag FromDateTimeOffset(DateTimeOffset time, TimestampTagStyles? style = null)
=> new(time, style);

/// <summary>
/// Immediately formats the provided time and style into a timestamp string.
/// </summary>
/// <param name="time">The time of this timestamp tag.</param>
/// <param name="style">The style for this timestamp tag.</param>
/// <returns>The newly create timestamp string.</returns>
public static string FormatFromDateTime(DateTime time, TimestampTagStyles style)
=> FormatFromDateTimeOffset(time, style);

/// <summary>
/// Immediately formats the provided time and style into a timestamp string.
/// </summary>
/// <param name="time">The time of this timestamp tag.</param>
/// <param name="style">The style for this timestamp tag.</param>
/// <returns>The newly create timestamp string.</returns>
public static string FormatFromDateTimeOffset(DateTimeOffset time, TimestampTagStyles style)
=> $"<t:{(time.ToUnixTimeSeconds()}:{(char)style}>";
}
}

Loading…
Cancel
Save