Skip to content

Facebook changed time formatting #95

Closed
@robbiet480

Description

@robbiet480

Seems that Facebook has changed the timestamp formatting on at least some routes, such as /<post_id>, to something resembling ISO8601. I have this code to parse it, I would submit a PR but not sure if its outside the scope of the project or if we should attempt to parse this new format in the existing code as part of decodeField/decode like we do for standard time.Time already:

type FacebookISO8601 time.Time

func (it FacebookISO8601) MarshalJSON() ([]byte, error) {
	return []byte(time.Time(it).Format(`"2006-01-02T15:04:05-0700"`)), nil
}

func (it *FacebookISO8601) UnmarshalJSON(data []byte) error {
	t, err := time.ParseInLocation(`"2006-01-02T15:04:05-0700"`, string(data), time.UTC)
	if err == nil {
		*it = FacebookISO8601(t)
	}

	return err
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions