@@ -15,7 +15,7 @@ namespace Discord
/// <summary>
/// <summary>
/// Gets or sets the time for this timestamp tag.
/// Gets or sets the time for this timestamp tag.
/// </summary>
/// </summary>
public DateTime Time { get; set; }
public DateTimeOffset Time { get; set; }
/// <summary>
/// <summary>
/// Converts the current timestamp tag to the string representation supported by discord.
/// Converts the current timestamp tag to the string representation supported by discord.
@@ -26,11 +26,11 @@ namespace Discord
/// <returns>A string that is compatible in a discord message, ex: <code><t:1625944201:f></code></returns>
/// <returns>A string that is compatible in a discord message, ex: <code><t:1625944201:f></code></returns>
public override string ToString()
public override string ToString()
{
{
return $"<t:{((Date TimeOffset)Time) .ToUnixTimeSeconds()}:{(char)Style}>";
return $"<t:{Time.ToUnixTimeSeconds()}:{(char)Style}>";
}
}
/// <summary>
/// <summary>
/// Creates a new timestamp tag with the specified datetime object.
/// Creates a new timestamp tag with the specified <see cref="DateTime"/> object.
/// </summary>
/// </summary>
/// <param name="time">The time of this timestamp tag.</param>
/// <param name="time">The time of this timestamp tag.</param>
/// <param name="style">The style for this timestamp tag.</param>
/// <param name="style">The style for this timestamp tag.</param>
@@ -43,5 +43,20 @@ namespace Discord
Time = time
Time = time
};
};
}
}
/// <summary>
/// Creates a new timestamp tag with the specified <see cref="DateTimeOffset"/> object.
/// </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 tag.</returns>
public static TimestampTag FromDateTimeOffset(DateTimeOffset time, TimestampTagStyles style = TimestampTagStyles.ShortDateTime)
{
return new TimestampTag
{
Style = style,
Time = time
};
}
}
}
}
}