From 553055b724176d812e2b2c2ba9ae3955b7c341fb Mon Sep 17 00:00:00 2001 From: sabihoshi <25006819+sabihoshi@users.noreply.github.com> Date: Thu, 3 Mar 2022 02:46:51 +0800 Subject: [PATCH] feat: Add FromDateTimeOffset in TimestampTag (#2146) --- .../Entities/Messages/TimestampTag.cs | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/Discord.Net.Core/Entities/Messages/TimestampTag.cs b/src/Discord.Net.Core/Entities/Messages/TimestampTag.cs index 347b0daaa..3beffdbb6 100644 --- a/src/Discord.Net.Core/Entities/Messages/TimestampTag.cs +++ b/src/Discord.Net.Core/Entities/Messages/TimestampTag.cs @@ -15,7 +15,7 @@ namespace Discord /// /// Gets or sets the time for this timestamp tag. /// - public DateTime Time { get; set; } + public DateTimeOffset Time { get; set; } /// /// Converts the current timestamp tag to the string representation supported by discord. @@ -26,11 +26,11 @@ namespace Discord /// A string that is compatible in a discord message, ex: <t:1625944201:f> public override string ToString() { - return $""; + return $""; } /// - /// Creates a new timestamp tag with the specified datetime object. + /// Creates a new timestamp tag with the specified object. /// /// The time of this timestamp tag. /// The style for this timestamp tag. @@ -43,5 +43,20 @@ namespace Discord Time = time }; } + + /// + /// Creates a new timestamp tag with the specified object. + /// + /// The time of this timestamp tag. + /// The style for this timestamp tag. + /// The newly create timestamp tag. + public static TimestampTag FromDateTimeOffset(DateTimeOffset time, TimestampTagStyles style = TimestampTagStyles.ShortDateTime) + { + return new TimestampTag + { + Style = style, + Time = time + }; + } } -} +} \ No newline at end of file