Is "UTC" a valid time zone name for RFC 1123?

I work against the API and request RFC 1123 dates. If I send requests with a date similar Thu, 04 Sep 2014 06:42:22 UTC, it is rejected because of the part "UTC". If I manipulate the string and create part of the time zone "GMT", it works.

I also noticed that many languages ​​(Java, C #, Python) format UTC dates in RFC 1123 format with the timezone string "GMT", however the language I use, Go, saves it as "UTC".

I am trying to figure out whether to use a language error or "UTC"in general in the RFC: http://www.ietf.org/rfc/rfc1123.txt

+4
source share
1 answer

Short answer

Use UTor GMT, but not UTC.

RFC 1123

My reading of RFC 1123 is that it uses RFC 822 for date and time formats other than tweets.

RFC 822

RFC 822 does not contain a word UTC. Instead, a UTsynonym is indicated on page 25 GMT. So you can use UT, but not UTC.

RFC 2822

In addition, RFC 822 has been replaced by RFC 2822 (yes, nice numbering). This specification only mentions UTC once, defining time zone offsets. But this specification does not add UTCas identifier in format. The same rule uses only GMTor UTin your lines.

ISO 8601

, RFC 822 1123, . , , , , UT GMT, , , UT UTC , 3 4 , , .

, ISO 8601, "" . RFC 822. ISO 8601 /.

ISO 8601:

2014-09-06T13:35:58-02:00
2014-09-06T15:35:58Z

, Go, UTC , .

java.time

FYI, Java , java.time. Java 8 , back-ported Java 6 7 Android. OpenJDK.

java.time ISO 8601 / .

, DateTimeFormatter http://tools.ietf.org/html/rfc1123, DateTimeFormatter.RFC_1123_DATE_TIME , Tue, 3 Jun 2008 11:05:30 GMT.

code live in IdeOne.com.

Instant instant = Instant.now() ; // Current moment in UTC.
OffsetDateTime odt = instant.atOffset( ZoneOffset.UTC ) ; // A wrapper around Instant, more flexible such as formatting.
DateTimeFormatter f = DateTimeFormatter.RFC_1123_DATE_TIME ;
String output = odt.format( f ) ;

instant.toString(): 2016-11-15T21:12: 49.261Z

odt.toString(): 2016-11-15T21:12: 49.261Z

output: Tue, 15 2016 21:12:49 GMT

+10

All Articles