Visitar URL original
First cut of timezone support in the API · JavaLeaks/developer.github.com@12a1ee8 · GitHub
Skip to content

Commit 12a1ee8

Browse files
committed
First cut of timezone support in the API
1 parent b02a8a7 commit 12a1ee8

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
kind: change
3+
title: Improved timezone handling in the API
4+
created_at: 2014-02-27
5+
author_name: dbussink
6+
---
7+
8+
Timezones always present interesting engineering problems. Git already handles
9+
this by allowing for timezone offset information in for example commits. We have
10+
improved support in our API as well. If you create commits through the API, we
11+
now allow for specifying timezone information more accurately.
12+
13+
We use the following steps to determine the timezone we use when a timestamp is
14+
generated in the API. These steps are ordered by priority, so we use the first
15+
case in this list that applies to the call you make.
16+
17+
#### Explicitly provide an ISO 8601 timestamp with timezone information
18+
19+
For API call that allows for a timestamp to be specified, we use that exact
20+
timestamp. An example of this is the [Commits API](v3/git/commits).
21+
22+
These timestamps look something like `2014-02-27T15:05:06+01:00`
23+
24+
#### Using the `Time-Zone` header
25+
26+
It is possible to supply a `Time-Zone` header which defines a timezone according
27+
to the [list of names from the Olson database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
28+
29+
This means that we generate a timestamp for the moment your API call is made in
30+
the timezone this header defines. For example the [Contents API](v3/repos/contents/)
31+
generates a git commit for each addition or change and uses the current time
32+
as the timestamp. This header will determine the time zone used for generating
33+
that current timestamp.
34+
35+
#### Using the last known timezone for the user
36+
37+
If no `Time-Zone` header is specified and you make an authenticated call to the
38+
API, we use the last known timezone for the authenticated user. The last know
39+
timezone is updated whenever you browse the GitHub.com website.
40+
41+
#### UTC
42+
43+
If the steps above don't result in any information, we use UTC as the timezone
44+
to create the git commit.
45+
46+
[contact]: https://github.com/contact?form[subject]=API+timezones

0 commit comments

Comments
 (0)