طلبات المناطق الزمنية
يتم إنشاء طلبات واجهة برمجة تطبيقات المنطقة الزمنية كسلسلة عنوان URL. تعرض واجهة برمجة التطبيقات بيانات المنطقة الزمنية لنقطة على الأرض، يتم تحديدها بواسطة زوج من خط العرض/الطول. تجدر الإشارة إلى أن بيانات المنطقة الزمنية قد لا تكون متاحة للمواقع الجغرافية فوق الماء، مثل المحيطات أو البحار.
يظهر طلب واجهة برمجة تطبيقات المنطقة الزمنية بالشكل التالي:
https://maps.googleapis.com/maps/api/timezone/outputFormat?parameters
حيث outputFormat
يمكن أن يكون أيًا من القيم التالية:
- تشير القيمة
json
(مُقترَحة) إلى المخرجات في JavaScript Object Notation (JSON)، أو - تشير قيمة
xml
إلى الناتج بتنسيق XML، ويتم لفّه في عقدة<TimeZoneResponse>
.
ملاحظة: يجب أن تكون عناوين URL مشفّرة بشكل صحيح لتكون صالحة ومقتصرة على 8192 حرفًا في جميع خدمات الويب. يُرجى الانتباه إلى هذا الحد عند إنشاء عناوين 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 thelocation
.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 theAccept-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.
Generated from the OpenAPI specification. Edit Report bug
أمثلة على المنطقة الزمنية
يتضمن هذا القسم بعض نماذج طلبات البحث التي توضح ميزات واجهة برمجة التطبيقات.
ينفّذ طلب البحث أدناه طلب منطقة زمنية لولاية نيفادا بالولايات المتحدة الأمريكية. تم تعيين الطابع الزمني في الثامن من آذار (مارس) 2012.
عنوان URL
https://maps.googleapis.com/maps/api/timezone/json ?location=39.6034810%2C-119.6822510 ×tamp=1331161200 &key=YOUR_API_KEY
cURL
curl -L -X GET 'https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810%2C-119.6822510×tamp=1331161200&key=YOUR_API_KEY'
JavaScript
var axios = require('axios'); var config = { method: 'get', url: 'https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810%2C-119.6822510×tamp=1331161200&key=YOUR_API_KEY', headers: { } }; axios(config) .then(function (response) { console.log(JSON.stringify(response.data)); }) .catch(function (error) { console.log(error); });
لغة Python
import requests url = "https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810%2C-119.6822510×tamp=1331161200&key=YOUR_API_KEY" payload={} headers = {} response = requests.request("GET", url, headers=headers, data=payload) print(response.text)
لغة Java
OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("text/plain"); RequestBody body = RequestBody.create(mediaType, ""); Request request = new Request.Builder() .url("https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810%2C-119.6822510×tamp=1331161200&key=YOUR_API_KEY") .method("GET", body) .build(); Response response = client.newCall(request).execute();
Ruby
require "uri" require "net/http" url = URI("https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810%2C-119.6822510×tamp=1331161200&key=YOUR_API_KEY") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) response = https.request(request) puts response.read_body
البدء
package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810,-119.6822510×tamp=1331161200&key=YOUR_API_KEY" method := "GET" client := &http.Client { } req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) return } res, err := client.Do(req) if err != nil { fmt.Println(err) return } defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } fmt.Println(string(body)) }
ساعي البريد
تتوفر أيضًا مواصفات OpenAPI كمجموعة Postman.
Run in PostmanJSON
{ "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>
ينفّذ طلب البحث أدناه طلب منطقة زمنية لولاية نيفادا بالولايات المتحدة الأمريكية. الموقع الجغرافي مماثل للطلب أعلاه، لكن الطابع الزمني مضبوط على 15 آذار (مارس) 2012. تتضمن الاستجابة الآن معادلة التوقيت الصيفي.
عنوان URL
https://maps.googleapis.com/maps/api/timezone/json ?location=39.6034810%2C-119.6822510 ×tamp=1331766000 &key=YOUR_API_KEY
cURL
curl -L -X GET 'https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810%2C-119.6822510×tamp=1331766000&key=YOUR_API_KEY'
JavaScript
var axios = require('axios'); var config = { method: 'get', url: 'https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810%2C-119.6822510×tamp=1331766000&key=YOUR_API_KEY', headers: { } }; axios(config) .then(function (response) { console.log(JSON.stringify(response.data)); }) .catch(function (error) { console.log(error); });
لغة Python
import requests url = "https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810%2C-119.6822510×tamp=1331766000&key=YOUR_API_KEY" payload={} headers = {} response = requests.request("GET", url, headers=headers, data=payload) print(response.text)
لغة Java
OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("text/plain"); RequestBody body = RequestBody.create(mediaType, ""); Request request = new Request.Builder() .url("https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810%2C-119.6822510×tamp=1331766000&key=YOUR_API_KEY") .method("GET", body) .build(); Response response = client.newCall(request).execute();
Ruby
require "uri" require "net/http" url = URI("https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810%2C-119.6822510×tamp=1331766000&key=YOUR_API_KEY") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) response = https.request(request) puts response.read_body
البدء
package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810,-119.6822510×tamp=1331766000&key=YOUR_API_KEY" method := "GET" client := &http.Client { } req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) return } res, err := client.Do(req) if err != nil { fmt.Println(err) return } defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } fmt.Println(string(body)) }
ساعي البريد
تتوفر أيضًا مواصفات OpenAPI كمجموعة Postman.
Run in PostmanJSON
{ "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 ×tamp=1331766000 &key=YOUR_API_KEY
cURL
curl -L -X GET 'https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810%2C-119.6822510×tamp=1331766000&language=es&key=YOUR_API_KEY'
JavaScript
var axios = require('axios'); var config = { method: 'get', url: 'https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810%2C-119.6822510×tamp=1331766000&language=es&key=YOUR_API_KEY', headers: { } }; axios(config) .then(function (response) { console.log(JSON.stringify(response.data)); }) .catch(function (error) { console.log(error); });
لغة Python
import requests url = "https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810%2C-119.6822510×tamp=1331766000&language=es&key=YOUR_API_KEY" payload={} headers = {} response = requests.request("GET", url, headers=headers, data=payload) print(response.text)
لغة Java
OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("text/plain"); RequestBody body = RequestBody.create(mediaType, ""); Request request = new Request.Builder() .url("https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810%2C-119.6822510×tamp=1331766000&language=es&key=YOUR_API_KEY") .method("GET", body) .build(); Response response = client.newCall(request).execute();
Ruby
require "uri" require "net/http" url = URI("https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810%2C-119.6822510×tamp=1331766000&language=es&key=YOUR_API_KEY") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) response = https.request(request) puts response.read_body
البدء
package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810,-119.6822510×tamp=1331766000&language=es&key=YOUR_API_KEY" method := "GET" client := &http.Client { } req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) return } res, err := client.Do(req) if err != nil { fmt.Println(err) return } defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } fmt.Println(string(body)) }
ساعي البريد
تتوفر أيضًا مواصفات OpenAPI كمجموعة Postman.
Run in PostmanJSON
{ "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
Field | Required | Type | Description |
---|---|---|---|
| required | TimeZoneStatus | See TimeZoneStatus for more information. |
| optional | number |
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 |
| optional | string |
Detailed information about the reasons behind the given status code.
Included if status other than |
| optional | number | The offset from UTC (in seconds) for the given location. This does not take into effect daylight savings. |
| optional | string | 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". |
| optional | string |
The long form name of the time zone. This field will be localized if
the language parameter is set. eg.
|
Generated from the OpenAPI specification. Edit Report bug
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.
Generated from the OpenAPI specification. Edit Report bug
حساب الوقت المحلي
الوقت المحلي لموقع جغرافي معيّن هو مجموع
المعلَمة timestamp
، والحقلَين dstOffset
وrawOffset
من النتيجة.