시간대 요청 및 응답

Time Zone

Time Zone API 요청은 URL 문자열로 구성됩니다. API는 위도/경도 쌍으로 지정된 지구상의 한 지점의 시간대 데이터를 반환합니다. 시간대 데이터는 대양이나 바다와 같은 물 위의 위치에는 제공되지 않을 수도 있습니다.

시간대 요청의 형식은 다음과 같습니다.

https://maps.googleapis.com/maps/api/timezone/outputFormat?parameters

여기서 outputFormat는 다음 값 중 하나일 수 있습니다.

  • json (권장): JSON (JavaScript Object Notation) 형식으로 출력을 나타냅니다.
  • xml<TimeZoneResponse> 노드 내에 래핑된 XML 형식의 출력을 나타냅니다.

참고: URL이 유효하려면 올바르게 인코딩되어야 하며 모든 웹 서비스에서 URL이 16,384자로 제한됩니다. URL을 구성할 때 이 한도에 유의하세요. 브라우저, 프록시, 서버에 따라 URL 글자 수 제한이 다를 수 있습니다.

Required parameters

  • location

    A comma-separated latitude,longitude tuple, location=39.6034810,-119.6822510, representing the location to look up.

  • timestamp

    The desired time as seconds since midnight, January 1, 1970 UTC. The Time Zone API uses the timestamp to determine whether or not Daylight Savings should be applied, based on the time zone of the location.

    Note that the API does not take historical time zones into account. That is, if you specify a past timestamp, the API does not take into account the possibility that the location was previously in a different time zone.

Optional parameters

  • language

    The language in which to return results.

    • See the list of supported languages. Google often updates the supported languages, so this list may not be exhaustive.
    • If language is not supplied, the API attempts to use the preferred language as specified in the Accept-Language header.
    • The API does its best to provide a street address that is readable for both the user and locals. To achieve that goal, it returns street addresses in the local language, transliterated to a script readable by the user if necessary, observing the preferred language. All other addresses are returned in the preferred language. Address components are all returned in the same language, which is chosen from the first component.
    • If a name is not available in the preferred language, the API uses the closest match.
    • The preferred language has a small influence on the set of results that the API chooses to return, and the order in which they are returned. The geocoder interprets abbreviations differently depending on language, such as the abbreviations for street types, or synonyms that may be valid in one language but not in another. For example, utca and tér are synonyms for street in Hungarian.

시간대 예시

이 섹션에는 API의 기능을 보여주는 샘플 쿼리가 포함되어 있습니다.

아래 쿼리는 미국 네바다에 대해 시간대 요청을 수행합니다. 타임스탬프는 2012년 3월 8일로 설정됩니다.

URL

https://maps.googleapis.com/maps/api/timezone/json
  ?location=39.6034810%2C-119.6822510
  &timestamp=1331161200
  &key=YOUR_API_KEY

cURL

curl -L -X GET 'https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810%2C-119.6822510&timestamp=1331161200&key=YOUR_API_KEY'

JSON

{
  "dstOffset": 0,
  "rawOffset": -28800,
  "status": "OK",
  "timeZoneId": "America/Los_Angeles",
  "timeZoneName": "Pacific Standard Time",
}

XML

<TimeZoneResponse>
 <status>OK</status>
 <raw_offset>-28800.0000000</raw_offset>
 <dst_offset>0.0000000</dst_offset>
 <time_zone_id>America/Los_Angeles</time_zone_id>
 <time_zone_name>Pacific Standard Time</time_zone_name>
</TimeZoneResponse>

아래 쿼리는 미국 네바다에 대해 시간대 요청을 수행합니다. 위치는 위의 요청과 같지만 타임스탬프는 2012년 3월 15일로 설정됩니다. 이제 응답에 일광 절약 시간 오프셋이 포함됩니다.

URL

https://maps.googleapis.com/maps/api/timezone/json
  ?location=39.6034810%2C-119.6822510
  &timestamp=1331766000
  &key=YOUR_API_KEY

cURL

curl -L -X GET 'https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810%2C-119.6822510&timestamp=1331766000&key=YOUR_API_KEY'

JSON

{
  "dstOffset": 3600,
  "rawOffset": -28800,
  "status": "OK",
  "timeZoneId": "America/Los_Angeles",
  "timeZoneName": "Pacific Daylight Time",
}

XML

<TimeZoneResponse>
 <status>OK</status>
 <raw_offset>-28800.0000000</raw_offset>
 <dst_offset>3600.0000000</dst_offset>
 <time_zone_id>America/Los_Angeles</time_zone_id>
 <time_zone_name>Pacific Daylight Time</time_zone_name>
</TimeZoneResponse>

이 예시는 위의 두 예제와 비슷하지만 언어 매개변수를 설정합니다. 이제 응답이 스페인어로 현지화됩니다.

URL

https://maps.googleapis.com/maps/api/timezone/json
  ?language=es
  &location=39.6034810%2C-119.6822510
  &timestamp=1331766000
  &key=YOUR_API_KEY

cURL

curl -L -X GET 'https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810%2C-119.6822510&timestamp=1331766000&language=es&key=YOUR_API_KEY'

JSON

{
  "dstOffset": 3600,
  "rawOffset": -28800,
  "status": "OK",
  "timeZoneId": "America/Los_Angeles",
  "timeZoneName": "hora de verano del Pacífico",
}

XML

<TimeZoneResponse>
 <status>OK</status>
 <raw_offset>-28800.0000000</raw_offset>
 <dst_offset>3600.0000000</dst_offset>
 <time_zone_id>America/Los_Angeles</time_zone_id>
 <time_zone_name>hora de verano del Pacífico</time_zone_name>
</TimeZoneResponse>

시간대 응답

유효한 각 요청에 대해 시간대는 요청 URL에 표시된 형식으로 응답을 반환합니다.

TimeZoneResponse

FieldRequiredTypeDescription
requiredTimeZoneStatus See TimeZoneStatus for more information.
optionalnumber

The offset for daylight-savings time in seconds. This will be zero if the time zone is not in Daylight Savings Time during the specified timestamp.

optionalstring

Detailed information about the reasons behind the given status code. Included if status other than Ok.

optionalnumber

The offset from UTC (in seconds) for the given location. This does not take into effect daylight savings.

optionalstring

a string containing the ID of the time zone, such as "America/Los_Angeles" or "Australia/Sydney". These IDs are defined by Unicode Common Locale Data Repository (CLDR) project, and currently available in file timezone.xml. When a timezone has several IDs, the canonical one is returned. In xml responses, this is the first alias of each timezone. For example, "Asia/Calcutta" is returned, not "Asia/Kolkata".

optionalstring

The long form name of the time zone. This field will be localized if the language parameter is set. eg. Pacific Daylight Time or Australian Eastern Daylight Time.

TimeZoneStatus

The status field within the Time Zone response object contains the status of the request. The status field may contain the following values:

  • OK indicates that the request was successful.

  • INVALID_REQUEST indicates that the request was malformed.

  • OVER_DAILY_LIMIT indicates any of the following:

    • The API key is missing or invalid.
    • Billing has not been enabled on your account.
    • A self-imposed usage cap has been exceeded.
    • The provided method of payment is no longer valid (for example, a credit card has expired).
  • OVER_QUERY_LIMIT indicates the requestor has exceeded quota.

  • REQUEST_DENIED indicates that the API did not complete the request. Confirm that the request was sent over HTTPS instead of HTTP.

  • UNKNOWN_ERROR indicates an unknown error.

  • ZERO_RESULTS indicates that no time zone data could be found for the specified position or time. Confirm that the request is for a location on land, and not over water.

현지 시간 계산 중

지정된 위치의 현지 시간은 timestamp 매개변수와 결과에서 dstOffsetrawOffset 필드의 합계입니다.