[backend/masto-client] Fix datetime string handling

This commit is contained in:
Laura Hausmann 2024-02-14 18:33:26 +01:00
parent b5a63fd301
commit 8ca64f5d11
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
4 changed files with 11 additions and 4 deletions

View file

@ -74,8 +74,8 @@ public class NoteRenderer(
Renote = renote, //TODO: check if it's a pure renote
Quote = renote, //TODO: see above
ContentType = "text/x.misskeymarkdown",
CreatedAt = note.CreatedAt.ToString("O")[..^5],
EditedAt = note.UpdatedAt?.ToString("O")[..^5],
CreatedAt = note.CreatedAt.ToStringMastodon(),
EditedAt = note.UpdatedAt?.ToStringMastodon(),
RepliesCount = note.RepliesCount,
RenoteCount = note.RenoteCount,
FavoriteCount = 0, //FIXME

View file

@ -26,7 +26,7 @@ public class NotificationRenderer(NoteRenderer noteRenderer, UserRenderer userRe
Type = Notification.EncodeType(notification.Type),
Note = note,
Notifier = notifier,
CreatedAt = notification.CreatedAt.ToString("O")[..^5]
CreatedAt = notification.CreatedAt.ToStringMastodon()
};
return res;

View file

@ -23,7 +23,7 @@ public class UserRenderer(IOptions<Config.InstanceSection> config, MfmConverter
Acct = acct,
FullyQualifiedName = $"{user.Username}@{user.Host ?? config.Value.AccountDomain}",
IsLocked = user.IsLocked,
CreatedAt = user.CreatedAt.ToString("O")[..^5],
CreatedAt = user.CreatedAt.ToStringMastodon(),
FollowersCount = user.FollowersCount,
FollowingCount = user.FollowingCount,
StatusesCount = user.NotesCount,

View file

@ -0,0 +1,7 @@
namespace Iceshrimp.Backend.Core.Extensions;
public static class DateTimeExtensions {
public static string ToStringMastodon(this DateTime dateTime) {
return dateTime.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffK");
}
}