parse timestamp fields into time.Time

This commit is contained in:
Dan Anglin 2024-02-23 08:36:58 +00:00
parent 4cbf1d4b4d
commit db6017dccf
Signed by: dananglin
GPG key ID: 0C1D44CFBEE68638
3 changed files with 11 additions and 7 deletions

View file

@ -32,7 +32,7 @@ var accountDetailsFormat = `
ACCOUNT ID: ACCOUNT ID:
%s %s
CREATED AT: JOINED ON:
%s %s
STATS: STATS:
@ -144,7 +144,7 @@ func (c *showCommand) showAccount(gts *client.Client) error {
account.DisplayName, account.DisplayName,
account.Username, account.Username,
account.ID, account.ID,
account.CreatedAt, account.CreatedAt.Format("02 Jan 2006"),
account.FollowersCount, account.FollowersCount,
account.FollowingCount, account.FollowingCount,
account.StatusCount, account.StatusCount,

View file

@ -1,11 +1,13 @@
package model package model
import "time"
type Account struct { type Account struct {
Acct string `json:"acct"` Acct string `json:"acct"`
Avatar string `json:"avatar"` Avatar string `json:"avatar"`
AvatarStatic string `json:"avatar_static"` AvatarStatic string `json:"avatar_static"`
Bot bool `json:"bot"` Bot bool `json:"bot"`
CreatedAt string `json:"created_at"` CreatedAt time.Time `json:"created_at"`
CustomCSS string `json:"custom_css"` CustomCSS string `json:"custom_css"`
Discoverable bool `json:"discoverable"` Discoverable bool `json:"discoverable"`
DisplayName string `json:"display_name"` DisplayName string `json:"display_name"`
@ -19,7 +21,7 @@ type Account struct {
ID string `json:"id"` ID string `json:"id"`
LastStatusAt string `json:"last_status_at"` LastStatusAt string `json:"last_status_at"`
Locked bool `json:"locked"` Locked bool `json:"locked"`
MuteExpiresAt string `json:"mute_expires_at"` MuteExpiresAt time.Time `json:"mute_expires_at"`
Note string `json:"note"` Note string `json:"note"`
Role AccountRole `json:"role"` Role AccountRole `json:"role"`
Source Source `json:"source"` Source Source `json:"source"`

View file

@ -1,12 +1,14 @@
package model package model
import "time"
type Status struct { type Status struct {
Account Account `json:"account"` Account Account `json:"account"`
Application Application `json:"application"` Application Application `json:"application"`
Bookmarked bool `json:"bookmarked"` Bookmarked bool `json:"bookmarked"`
Card Card `json:"card"` Card Card `json:"card"`
Content string `json:"content"` Content string `json:"content"`
CreatedAt string `json:"created_at"` CreatedAt time.Time `json:"created_at"`
Emojis []Emoji `json:"emojis"` Emojis []Emoji `json:"emojis"`
Favourited bool `json:"favourited"` Favourited bool `json:"favourited"`
FavouritesCount int `json:"favourites_count"` FavouritesCount int `json:"favourites_count"`
@ -61,7 +63,7 @@ type Poll struct {
Expired bool `json:"expired"` Expired bool `json:"expired"`
Voted bool `json:"voted"` Voted bool `json:"voted"`
Multiple bool `json:"multiple"` Multiple bool `json:"multiple"`
ExpiredAt string `json:"expires_at"` ExpiredAt time.Time `json:"expires_at"`
ID string `json:"id"` ID string `json:"id"`
OwnVotes []int `json:"own_votes"` OwnVotes []int `json:"own_votes"`
VotersCount int `json:"voters_count"` VotersCount int `json:"voters_count"`
@ -80,7 +82,7 @@ type StatusReblogged struct {
Bookmarked bool `json:"bookmarked"` Bookmarked bool `json:"bookmarked"`
Card Card `json:"card"` Card Card `json:"card"`
Content string `json:"content"` Content string `json:"content"`
CreatedAt string `json:"created_at"` CreatedAt time.Time `json:"created_at"`
Emojis []Emoji `json:"emojis"` Emojis []Emoji `json:"emojis"`
Favourited bool `json:"favourited"` Favourited bool `json:"favourited"`
FavouritesCount int `json:"favourites_count"` FavouritesCount int `json:"favourites_count"`