From e080f324eda76a5ccf1147ececf111ad62aaf74a Mon Sep 17 00:00:00 2001 From: sabihoshi Date: Wed, 2 Mar 2022 01:55:18 +0800 Subject: [PATCH] feat: Add FromDateTimeOffset in TimestampTag --- .../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