DateTime
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
نشان دهنده زمان مدنی (یا گاهی اوقات زمان فیزیکی) است.
این نوع می تواند یک زمان مدنی را به یکی از چند روش ممکن نشان دهد:
- وقتی utcOffset تنظیم شده است و timeZone تنظیم نشده است: یک زمان مدنی در یک روز تقویمی با یک افست خاص از UTC.
- وقتی TimeZone تنظیم شده است و utcOffset تنظیم نشده است: یک زمان مدنی در یک روز تقویمی در یک منطقه زمانی خاص.
- وقتی نه timeZone و نه utcOffset تنظیم نشده است: یک زمان مدنی در یک روز تقویمی به وقت محلی.
تاریخ نسبت به تقویم گرگوری پرولپتیک است.
اگر سال، ماه یا روز 0 باشد، DateTime به ترتیب سال، ماه یا روز خاصی ندارد.
اگر تمام فیلدهای تاریخ و زمان تنظیم شده باشند و هر کدام از موارد time_offset
یکی از آنها تنظیم شده باشد، ممکن است برای نمایش زمان فیزیکی نیز استفاده شود. به جای آن از پیام Timestamp
برای زمان فیزیکی استفاده کنید. اگر مورد استفاده شما همچنین میخواهد منطقه زمانی کاربر را ذخیره کند، میتوانید در فیلد دیگری این کار را انجام دهید.
این نوع نسبت به برخی از برنامه ها انعطاف پذیرتر است. اطمینان حاصل کنید که محدودیت های برنامه خود را مستند و تأیید کنید.
نمایندگی JSON |
---|
{
"year": integer,
"month": integer,
"day": integer,
"hours": integer,
"minutes": integer,
"seconds": integer,
"nanos": integer,
// Union field time_offset can be only one of the following:
"utcOffset": string,
"timeZone": {
object (TimeZone )
}
// End of list of possible types for union field time_offset .
} |
فیلدها |
---|
year | integer اختیاری. سال تاریخ. باید از 1 تا 9999 یا در صورت تعیین تاریخ بدون سال، 0 باشد. |
month | integer اختیاری. ماه سال. باید از 1 تا 12 یا در صورت تعیین تاریخ بدون ماه، 0 باشد. |
day | integer اختیاری. روز ماه. باید از 1 تا 31 باشد و برای سال و ماه معتبر باشد، یا در صورت تعیین تاریخ بدون روز، 0 باشد. |
hours | integer اختیاری. ساعات روز در قالب 24 ساعته. باید از 0 تا 23، پیشفرض روی 0 (نیمه شب) باشد. یک API ممکن است برای سناریوهایی مانند زمان بسته شدن کسب و کار، مقدار "24:00:00" را مجاز کند. |
minutes | integer اختیاری. دقیقه از ساعت روز. باید از 0 تا 59 باشد، پیشفرض 0 باشد. |
seconds | integer اختیاری. ثانیه های دقیقه از زمان. معمولاً باید از 0 تا 59 باشد، به طور پیشفرض 0 باشد. اگر API به ثانیههای کبیسه اجازه دهد، ممکن است مقدار 60 را مجاز کند. |
nanos | integer اختیاری. کسری از ثانیه در نانوثانیه. باید از 0 تا 999,999,999 باشد، پیشفرض 0 باشد. |
میدان اتحادیه time_offset . اختیاری. افست UTC یا منطقه زمانی DateTime را مشخص می کند. با توجه به اینکه دادههای منطقه زمانی ممکن است در آینده تغییر کند، بین آنها با دقت انتخاب کنید (به عنوان مثال، یک کشور تاریخهای شروع/پایان DST خود را تغییر میدهد و تاریخهای آینده در محدوده تحت تأثیر قبلاً ذخیره شده است). اگر حذف شود، DateTime به وقت محلی در نظر گرفته می شود. time_offset تنها می تواند یکی از موارد زیر باشد: |
utc Offset | string ( Duration format) افست UTC. باید ثانیه های کامل، بین -18 ساعت و +18 ساعت باشد. به عنوان مثال، یک افست UTC از -4:00 به صورت { ثانیه: -14400 } نشان داده می شود. مدت زمان در ثانیه با حداکثر نه رقم کسری که با ' s ' ختم می شود. مثال: "3.5s" . |
time Zone | object ( TimeZone ) منطقه زمانی |
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# DateTime\n\n- [JSON representation](#SCHEMA_REPRESENTATION)\n\nRepresents civil time (or occasionally physical time).\n\nThis type can represent a civil time in one of a few possible ways:\n\n- When utcOffset is set and timeZone is unset: a civil time on a calendar day with a particular offset from UTC.\n- When timeZone is set and utcOffset is unset: a civil time on a calendar day in a particular time zone.\n- When neither timeZone nor utcOffset is set: a civil time on a calendar day in local time.\n\nThe date is relative to the Proleptic Gregorian Calendar.\n\nIf year, month, or day are 0, the DateTime is considered not to have a specific year, month, or day respectively.\n\nThis type may also be used to represent a physical time if all the date and time fields are set and either case of the `time_offset` oneof is set. Consider using `Timestamp` message for physical time instead. If your use case also would like to store the user's timezone, that can be done in another field.\n\nThis type is more flexible than some applications may want. Make sure to document and validate your application's limitations.\n\n| JSON representation |\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"year\": integer, \"month\": integer, \"day\": integer, \"hours\": integer, \"minutes\": integer, \"seconds\": integer, \"nanos\": integer, // Union field `time_offset` can be only one of the following: \"utcOffset\": string, \"timeZone\": { object (/maps/documentation/weather/reference/rest/v1/TimeZone) } // End of list of possible types for union field `time_offset`. } ``` |\n\n| Fields ||\n|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `year` | `integer` Optional. Year of date. Must be from 1 to 9999, or 0 if specifying a datetime without a year. |\n| `month` | `integer` Optional. Month of year. Must be from 1 to 12, or 0 if specifying a datetime without a month. |\n| `day` | `integer` Optional. Day of month. Must be from 1 to 31 and valid for the year and month, or 0 if specifying a datetime without a day. |\n| `hours` | `integer` Optional. Hours of day in 24 hour format. Should be from 0 to 23, defaults to 0 (midnight). An API may choose to allow the value \"24:00:00\" for scenarios like business closing time. |\n| `minutes` | `integer` Optional. Minutes of hour of day. Must be from 0 to 59, defaults to 0. |\n| `seconds` | `integer` Optional. Seconds of minutes of the time. Must normally be from 0 to 59, defaults to 0. An API may allow the value 60 if it allows leap-seconds. |\n| `nanos` | `integer` Optional. Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999, defaults to 0. |\n| Union field `time_offset`. Optional. Specifies either the UTC offset or the time zone of the DateTime. Choose carefully between them, considering that time zone data may change in the future (for example, a country modifies their DST start/end dates, and future DateTimes in the affected range had already been stored). If omitted, the DateTime is considered to be in local time. `time_offset` can be only one of the following: ||\n| `utc``Offset` | `string (`[Duration](https://protobuf.dev/reference/protobuf/google.protobuf/#duration)` format)` UTC offset. Must be whole seconds, between -18 hours and +18 hours. For example, a UTC offset of -4:00 would be represented as { seconds: -14400 }. A duration in seconds with up to nine fractional digits, ending with '`s`'. Example: `\"3.5s\"`. |\n| `time``Zone` | `object (`[TimeZone](/maps/documentation/weather/reference/rest/v1/TimeZone)`)` Time zone. |"]]