go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/milo/ui/src/proto/google/protobuf/timestamp.pb.ts (about)

     1  /* eslint-disable */
     2  import Long from "long";
     3  import _m0 from "protobufjs/minimal";
     4  
     5  export const protobufPackage = "google.protobuf";
     6  
     7  /**
     8   * A Timestamp represents a point in time independent of any time zone or local
     9   * calendar, encoded as a count of seconds and fractions of seconds at
    10   * nanosecond resolution. The count is relative to an epoch at UTC midnight on
    11   * January 1, 1970, in the proleptic Gregorian calendar which extends the
    12   * Gregorian calendar backwards to year one.
    13   *
    14   * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
    15   * second table is needed for interpretation, using a [24-hour linear
    16   * smear](https://developers.google.com/time/smear).
    17   *
    18   * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
    19   * restricting to that range, we ensure that we can convert to and from [RFC
    20   * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
    21   *
    22   * # Examples
    23   *
    24   * Example 1: Compute Timestamp from POSIX `time()`.
    25   *
    26   *     Timestamp timestamp;
    27   *     timestamp.set_seconds(time(NULL));
    28   *     timestamp.set_nanos(0);
    29   *
    30   * Example 2: Compute Timestamp from POSIX `gettimeofday()`.
    31   *
    32   *     struct timeval tv;
    33   *     gettimeofday(&tv, NULL);
    34   *
    35   *     Timestamp timestamp;
    36   *     timestamp.set_seconds(tv.tv_sec);
    37   *     timestamp.set_nanos(tv.tv_usec * 1000);
    38   *
    39   * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
    40   *
    41   *     FILETIME ft;
    42   *     GetSystemTimeAsFileTime(&ft);
    43   *     UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
    44   *
    45   *     // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
    46   *     // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
    47   *     Timestamp timestamp;
    48   *     timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
    49   *     timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
    50   *
    51   * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
    52   *
    53   *     long millis = System.currentTimeMillis();
    54   *
    55   *     Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
    56   *         .setNanos((int) ((millis % 1000) * 1000000)).build();
    57   *
    58   * Example 5: Compute Timestamp from Java `Instant.now()`.
    59   *
    60   *     Instant now = Instant.now();
    61   *
    62   *     Timestamp timestamp =
    63   *         Timestamp.newBuilder().setSeconds(now.getEpochSecond())
    64   *             .setNanos(now.getNano()).build();
    65   *
    66   * Example 6: Compute Timestamp from current time in Python.
    67   *
    68   *     timestamp = Timestamp()
    69   *     timestamp.GetCurrentTime()
    70   *
    71   * # JSON Mapping
    72   *
    73   * In JSON format, the Timestamp type is encoded as a string in the
    74   * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
    75   * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
    76   * where {year} is always expressed using four digits while {month}, {day},
    77   * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
    78   * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
    79   * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
    80   * is required. A proto3 JSON serializer should always use UTC (as indicated by
    81   * "Z") when printing the Timestamp type and a proto3 JSON parser should be
    82   * able to accept both UTC and other timezones (as indicated by an offset).
    83   *
    84   * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
    85   * 01:30 UTC on January 15, 2017.
    86   *
    87   * In JavaScript, one can convert a Date object to this format using the
    88   * standard
    89   * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
    90   * method. In Python, a standard `datetime.datetime` object can be converted
    91   * to this format using
    92   * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
    93   * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
    94   * the Joda Time's [`ISODateTimeFormat.dateTime()`](
    95   * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D
    96   * ) to obtain a formatter capable of generating timestamps in this format.
    97   */
    98  export interface Timestamp {
    99    /**
   100     * Represents seconds of UTC time since Unix epoch
   101     * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
   102     * 9999-12-31T23:59:59Z inclusive.
   103     */
   104    readonly seconds: string;
   105    /**
   106     * Non-negative fractions of a second at nanosecond resolution. Negative
   107     * second values with fractions must still have non-negative nanos values
   108     * that count forward in time. Must be from 0 to 999,999,999
   109     * inclusive.
   110     */
   111    readonly nanos: number;
   112  }
   113  
   114  function createBaseTimestamp(): Timestamp {
   115    return { seconds: "0", nanos: 0 };
   116  }
   117  
   118  export const Timestamp = {
   119    encode(message: Timestamp, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
   120      if (message.seconds !== "0") {
   121        writer.uint32(8).int64(message.seconds);
   122      }
   123      if (message.nanos !== 0) {
   124        writer.uint32(16).int32(message.nanos);
   125      }
   126      return writer;
   127    },
   128  
   129    decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp {
   130      const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
   131      let end = length === undefined ? reader.len : reader.pos + length;
   132      const message = createBaseTimestamp() as any;
   133      while (reader.pos < end) {
   134        const tag = reader.uint32();
   135        switch (tag >>> 3) {
   136          case 1:
   137            if (tag !== 8) {
   138              break;
   139            }
   140  
   141            message.seconds = longToString(reader.int64() as Long);
   142            continue;
   143          case 2:
   144            if (tag !== 16) {
   145              break;
   146            }
   147  
   148            message.nanos = reader.int32();
   149            continue;
   150        }
   151        if ((tag & 7) === 4 || tag === 0) {
   152          break;
   153        }
   154        reader.skipType(tag & 7);
   155      }
   156      return message;
   157    },
   158  
   159    fromJSON(object: any): Timestamp {
   160      return {
   161        seconds: isSet(object.seconds) ? globalThis.String(object.seconds) : "0",
   162        nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0,
   163      };
   164    },
   165  
   166    toJSON(message: Timestamp): unknown {
   167      const obj: any = {};
   168      if (message.seconds !== "0") {
   169        obj.seconds = message.seconds;
   170      }
   171      if (message.nanos !== 0) {
   172        obj.nanos = Math.round(message.nanos);
   173      }
   174      return obj;
   175    },
   176  
   177    create<I extends Exact<DeepPartial<Timestamp>, I>>(base?: I): Timestamp {
   178      return Timestamp.fromPartial(base ?? ({} as any));
   179    },
   180    fromPartial<I extends Exact<DeepPartial<Timestamp>, I>>(object: I): Timestamp {
   181      const message = createBaseTimestamp() as any;
   182      message.seconds = object.seconds ?? "0";
   183      message.nanos = object.nanos ?? 0;
   184      return message;
   185    },
   186  };
   187  
   188  type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
   189  
   190  export type DeepPartial<T> = T extends Builtin ? T
   191    : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
   192    : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
   193    : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
   194    : Partial<T>;
   195  
   196  type KeysOfUnion<T> = T extends T ? keyof T : never;
   197  export type Exact<P, I extends P> = P extends Builtin ? P
   198    : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
   199  
   200  function longToString(long: Long) {
   201    return long.toString();
   202  }
   203  
   204  if (_m0.util.Long !== Long) {
   205    _m0.util.Long = Long as any;
   206    _m0.configure();
   207  }
   208  
   209  function isSet(value: any): boolean {
   210    return value !== null && value !== undefined;
   211  }