• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2021 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15syntax = "proto3";
16
17package google.type;
18
19import "google/protobuf/duration.proto";
20
21option cc_enable_arenas = true;
22option go_package = "google.golang.org/genproto/googleapis/type/datetime;datetime";
23option java_multiple_files = true;
24option java_outer_classname = "DateTimeProto";
25option java_package = "com.google.type";
26option objc_class_prefix = "GTP";
27
28// Represents civil time (or occasionally physical time).
29//
30// This type can represent a civil time in one of a few possible ways:
31//
32//  * When utc_offset is set and time_zone is unset: a civil time on a calendar
33//    day with a particular offset from UTC.
34//  * When time_zone is set and utc_offset is unset: a civil time on a calendar
35//    day in a particular time zone.
36//  * When neither time_zone nor utc_offset is set: a civil time on a calendar
37//    day in local time.
38//
39// The date is relative to the Proleptic Gregorian Calendar.
40//
41// If year is 0, the DateTime is considered not to have a specific year. month
42// and day must have valid, non-zero values.
43//
44// This type may also be used to represent a physical time if all the date and
45// time fields are set and either case of the `time_offset` oneof is set.
46// Consider using `Timestamp` message for physical time instead. If your use
47// case also would like to store the user's timezone, that can be done in
48// another field.
49//
50// This type is more flexible than some applications may want. Make sure to
51// document and validate your application's limitations.
52message DateTime {
53  // Optional. Year of date. Must be from 1 to 9999, or 0 if specifying a
54  // datetime without a year.
55  int32 year = 1;
56
57  // Required. Month of year. Must be from 1 to 12.
58  int32 month = 2;
59
60  // Required. Day of month. Must be from 1 to 31 and valid for the year and
61  // month.
62  int32 day = 3;
63
64  // Required. Hours of day in 24 hour format. Should be from 0 to 23. An API
65  // may choose to allow the value "24:00:00" for scenarios like business
66  // closing time.
67  int32 hours = 4;
68
69  // Required. Minutes of hour of day. Must be from 0 to 59.
70  int32 minutes = 5;
71
72  // Required. Seconds of minutes of the time. Must normally be from 0 to 59. An
73  // API may allow the value 60 if it allows leap-seconds.
74  int32 seconds = 6;
75
76  // Required. Fractions of seconds in nanoseconds. Must be from 0 to
77  // 999,999,999.
78  int32 nanos = 7;
79
80  // Optional. Specifies either the UTC offset or the time zone of the DateTime.
81  // Choose carefully between them, considering that time zone data may change
82  // in the future (for example, a country modifies their DST start/end dates,
83  // and future DateTimes in the affected range had already been stored).
84  // If omitted, the DateTime is considered to be in local time.
85  oneof time_offset {
86    // UTC offset. Must be whole seconds, between -18 hours and +18 hours.
87    // For example, a UTC offset of -4:00 would be represented as
88    // { seconds: -14400 }.
89    google.protobuf.Duration utc_offset = 8;
90
91    // Time zone.
92    TimeZone time_zone = 9;
93  }
94}
95
96// Represents a time zone from the
97// [IANA Time Zone Database](https://www.iana.org/time-zones).
98message TimeZone {
99  // IANA Time Zone Database time zone, e.g. "America/New_York".
100  string id = 1;
101
102  // Optional. IANA Time Zone Database version number, e.g. "2019a".
103  string version = 2;
104}
105