datetime.proto 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. syntax = "proto3";
  15. package google.type;
  16. import "google/protobuf/duration.proto";
  17. option cc_enable_arenas = true;
  18. option go_package = "google.golang.org/genproto/googleapis/type/datetime;datetime";
  19. option java_multiple_files = true;
  20. option java_outer_classname = "DateTimeProto";
  21. option java_package = "com.google.type";
  22. option objc_class_prefix = "GTP";
  23. // Represents civil time (or occasionally physical time).
  24. //
  25. // This type can represent a civil time in one of a few possible ways:
  26. //
  27. // * When utc_offset is set and time_zone is unset: a civil time on a calendar
  28. // day with a particular offset from UTC.
  29. // * When time_zone is set and utc_offset is unset: a civil time on a calendar
  30. // day in a particular time zone.
  31. // * When neither time_zone nor utc_offset is set: a civil time on a calendar
  32. // day in local time.
  33. //
  34. // The date is relative to the Proleptic Gregorian Calendar.
  35. //
  36. // If year is 0, the DateTime is considered not to have a specific year. month
  37. // and day must have valid, non-zero values.
  38. //
  39. // This type may also be used to represent a physical time if all the date and
  40. // time fields are set and either case of the `time_offset` oneof is set.
  41. // Consider using `Timestamp` message for physical time instead. If your use
  42. // case also would like to store the user's timezone, that can be done in
  43. // another field.
  44. //
  45. // This type is more flexible than some applications may want. Make sure to
  46. // document and validate your application's limitations.
  47. message DateTime {
  48. // Optional. Year of date. Must be from 1 to 9999, or 0 if specifying a
  49. // datetime without a year.
  50. int32 year = 1;
  51. // Required. Month of year. Must be from 1 to 12.
  52. int32 month = 2;
  53. // Required. Day of month. Must be from 1 to 31 and valid for the year and
  54. // month.
  55. int32 day = 3;
  56. // Required. Hours of day in 24 hour format. Should be from 0 to 23. An API
  57. // may choose to allow the value "24:00:00" for scenarios like business
  58. // closing time.
  59. int32 hours = 4;
  60. // Required. Minutes of hour of day. Must be from 0 to 59.
  61. int32 minutes = 5;
  62. // Required. Seconds of minutes of the time. Must normally be from 0 to 59. An
  63. // API may allow the value 60 if it allows leap-seconds.
  64. int32 seconds = 6;
  65. // Required. Fractions of seconds in nanoseconds. Must be from 0 to
  66. // 999,999,999.
  67. int32 nanos = 7;
  68. // Optional. Specifies either the UTC offset or the time zone of the DateTime.
  69. // Choose carefully between them, considering that time zone data may change
  70. // in the future (for example, a country modifies their DST start/end dates,
  71. // and future DateTimes in the affected range had already been stored).
  72. // If omitted, the DateTime is considered to be in local time.
  73. oneof time_offset {
  74. // UTC offset. Must be whole seconds, between -18 hours and +18 hours.
  75. // For example, a UTC offset of -4:00 would be represented as
  76. // { seconds: -14400 }.
  77. google.protobuf.Duration utc_offset = 8;
  78. // Time zone.
  79. TimeZone time_zone = 9;
  80. }
  81. }
  82. // Represents a time zone from the
  83. // [IANA Time Zone Database](https://www.iana.org/time-zones).
  84. message TimeZone {
  85. // IANA Time Zone Database time zone, e.g. "America/New_York".
  86. string id = 1;
  87. // Optional. IANA Time Zone Database version number, e.g. "2019a".
  88. string version = 2;
  89. }