summaryrefslogtreecommitdiff
path: root/internal/util/time.go
diff options
context:
space:
mode:
authorLibravatar Markus Unterwaditzer <markus-github@unterwaditzer.net>2024-10-12 10:02:26 +0200
committerLibravatar GitHub <noreply@github.com>2024-10-12 10:02:26 +0200
commit95a316236e3651c27d995fcdc8093ae0d1f96125 (patch)
tree13669ae1942d5ce0309a14933104a793cfcd4071 /internal/util/time.go
parent[chore] Don't cc Accept of likes to followers (#3417) (diff)
downloadgotosocial-95a316236e3651c27d995fcdc8093ae0d1f96125.tar.xz
[bugfix] Account.last_status_at is a date, not datetime (#3419)
* [bugfix] Account.last_status_at is a date, not datetime Fix #3418 * update swagger
Diffstat (limited to 'internal/util/time.go')
-rw-r--r--internal/util/time.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/internal/util/time.go b/internal/util/time.go
index 90e810078..0f874986a 100644
--- a/internal/util/time.go
+++ b/internal/util/time.go
@@ -21,6 +21,7 @@ import "time"
// ISO8601 is a formatter for serializing times that forces ISO8601 behavior.
const ISO8601 = "2006-01-02T15:04:05.000Z"
+const ISO8601Date = "2006-01-02"
// FormatISO8601 converts the given time to UTC and then formats it
// using the ISO8601 const, which the Mastodon API is able to understand.
@@ -28,6 +29,12 @@ func FormatISO8601(t time.Time) string {
return t.UTC().Format(ISO8601)
}
+// Mastodon returns UTC dates (without time) for last_status_at/LastStatusAt as
+// a special case, but most of the time you want to use FormatISO8601 instead.
+func FormatISO8601Date(t time.Time) string {
+ return t.UTC().Format(ISO8601Date)
+}
+
// ParseISO8601 parses the given time string according to the ISO8601 const.
func ParseISO8601(in string) (time.Time, error) {
return time.Parse(ISO8601, in)