JSON is more complex (for backward compatibility and user-friendliness):
encoding uses the RFC3339 format (e.g., "1970-01-01T00:00:00Z") if the year is between 0000 and 9999 (RFC3339-compatible); otherwise it uses the int64 format
decoding tries to decode as an RFC3339 notation, and if it fails, it decodes as int64.
Note: the RFC has a different range than the internal representation. Specifically, the RFC can only represent times between 0000-00-00 and 9999-12-31 (inclusive). The RFC-encoding fails for dates outside of this range.
For this reason, it is preferable to use encoding and only resort to rfc_encoding for human-readable format.
Note: pretty-printing uses the RFC3339 for human-readability. As mentioned in the comment on rfc_encoding, this representation fails when given dates too far in the future (after 9999-12-31) or the past (before 0000-00-00).