github.com/gogo/protobuf@v1.3.2/types/timestamp.pb.go (about) 1 // Code generated by protoc-gen-gogo. DO NOT EDIT. 2 // source: google/protobuf/timestamp.proto 3 4 package types 5 6 import ( 7 bytes "bytes" 8 fmt "fmt" 9 proto "github.com/gogo/protobuf/proto" 10 io "io" 11 math "math" 12 math_bits "math/bits" 13 reflect "reflect" 14 strings "strings" 15 ) 16 17 // Reference imports to suppress errors if they are not otherwise used. 18 var _ = proto.Marshal 19 var _ = fmt.Errorf 20 var _ = math.Inf 21 22 // This is a compile-time assertion to ensure that this generated file 23 // is compatible with the proto package it is being compiled against. 24 // A compilation error at this line likely means your copy of the 25 // proto package needs to be updated. 26 const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package 27 28 // A Timestamp represents a point in time independent of any time zone or local 29 // calendar, encoded as a count of seconds and fractions of seconds at 30 // nanosecond resolution. The count is relative to an epoch at UTC midnight on 31 // January 1, 1970, in the proleptic Gregorian calendar which extends the 32 // Gregorian calendar backwards to year one. 33 // 34 // All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap 35 // second table is needed for interpretation, using a [24-hour linear 36 // smear](https://developers.google.com/time/smear). 37 // 38 // The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By 39 // restricting to that range, we ensure that we can convert to and from [RFC 40 // 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. 41 // 42 // # Examples 43 // 44 // Example 1: Compute Timestamp from POSIX `time()`. 45 // 46 // Timestamp timestamp; 47 // timestamp.set_seconds(time(NULL)); 48 // timestamp.set_nanos(0); 49 // 50 // Example 2: Compute Timestamp from POSIX `gettimeofday()`. 51 // 52 // struct timeval tv; 53 // gettimeofday(&tv, NULL); 54 // 55 // Timestamp timestamp; 56 // timestamp.set_seconds(tv.tv_sec); 57 // timestamp.set_nanos(tv.tv_usec * 1000); 58 // 59 // Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. 60 // 61 // FILETIME ft; 62 // GetSystemTimeAsFileTime(&ft); 63 // UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; 64 // 65 // // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z 66 // // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. 67 // Timestamp timestamp; 68 // timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); 69 // timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); 70 // 71 // Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. 72 // 73 // long millis = System.currentTimeMillis(); 74 // 75 // Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) 76 // .setNanos((int) ((millis % 1000) * 1000000)).build(); 77 // 78 // 79 // Example 5: Compute Timestamp from current time in Python. 80 // 81 // timestamp = Timestamp() 82 // timestamp.GetCurrentTime() 83 // 84 // # JSON Mapping 85 // 86 // In JSON format, the Timestamp type is encoded as a string in the 87 // [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the 88 // format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" 89 // where {year} is always expressed using four digits while {month}, {day}, 90 // {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional 91 // seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), 92 // are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone 93 // is required. A proto3 JSON serializer should always use UTC (as indicated by 94 // "Z") when printing the Timestamp type and a proto3 JSON parser should be 95 // able to accept both UTC and other timezones (as indicated by an offset). 96 // 97 // For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past 98 // 01:30 UTC on January 15, 2017. 99 // 100 // In JavaScript, one can convert a Date object to this format using the 101 // standard 102 // [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) 103 // method. In Python, a standard `datetime.datetime` object can be converted 104 // to this format using 105 // [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with 106 // the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use 107 // the Joda Time's [`ISODateTimeFormat.dateTime()`]( 108 // http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D 109 // ) to obtain a formatter capable of generating timestamps in this format. 110 // 111 // 112 type Timestamp struct { 113 // Represents seconds of UTC time since Unix epoch 114 // 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to 115 // 9999-12-31T23:59:59Z inclusive. 116 Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"` 117 // Non-negative fractions of a second at nanosecond resolution. Negative 118 // second values with fractions must still have non-negative nanos values 119 // that count forward in time. Must be from 0 to 999,999,999 120 // inclusive. 121 Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"` 122 XXX_NoUnkeyedLiteral struct{} `json:"-"` 123 XXX_unrecognized []byte `json:"-"` 124 XXX_sizecache int32 `json:"-"` 125 } 126 127 func (m *Timestamp) Reset() { *m = Timestamp{} } 128 func (*Timestamp) ProtoMessage() {} 129 func (*Timestamp) Descriptor() ([]byte, []int) { 130 return fileDescriptor_292007bbfe81227e, []int{0} 131 } 132 func (*Timestamp) XXX_WellKnownType() string { return "Timestamp" } 133 func (m *Timestamp) XXX_Unmarshal(b []byte) error { 134 return m.Unmarshal(b) 135 } 136 func (m *Timestamp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 137 if deterministic { 138 return xxx_messageInfo_Timestamp.Marshal(b, m, deterministic) 139 } else { 140 b = b[:cap(b)] 141 n, err := m.MarshalToSizedBuffer(b) 142 if err != nil { 143 return nil, err 144 } 145 return b[:n], nil 146 } 147 } 148 func (m *Timestamp) XXX_Merge(src proto.Message) { 149 xxx_messageInfo_Timestamp.Merge(m, src) 150 } 151 func (m *Timestamp) XXX_Size() int { 152 return m.Size() 153 } 154 func (m *Timestamp) XXX_DiscardUnknown() { 155 xxx_messageInfo_Timestamp.DiscardUnknown(m) 156 } 157 158 var xxx_messageInfo_Timestamp proto.InternalMessageInfo 159 160 func (m *Timestamp) GetSeconds() int64 { 161 if m != nil { 162 return m.Seconds 163 } 164 return 0 165 } 166 167 func (m *Timestamp) GetNanos() int32 { 168 if m != nil { 169 return m.Nanos 170 } 171 return 0 172 } 173 174 func (*Timestamp) XXX_MessageName() string { 175 return "google.protobuf.Timestamp" 176 } 177 func init() { 178 proto.RegisterType((*Timestamp)(nil), "google.protobuf.Timestamp") 179 } 180 181 func init() { proto.RegisterFile("google/protobuf/timestamp.proto", fileDescriptor_292007bbfe81227e) } 182 183 var fileDescriptor_292007bbfe81227e = []byte{ 184 // 212 bytes of a gzipped FileDescriptorProto 185 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0xcf, 0xcf, 0x4f, 186 0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x2f, 0xc9, 0xcc, 0x4d, 187 0x2d, 0x2e, 0x49, 0xcc, 0x2d, 0xd0, 0x03, 0x0b, 0x09, 0xf1, 0x43, 0x14, 0xe8, 0xc1, 0x14, 0x28, 188 0x59, 0x73, 0x71, 0x86, 0xc0, 0xd4, 0x08, 0x49, 0x70, 0xb1, 0x17, 0xa7, 0x26, 0xe7, 0xe7, 0xa5, 189 0x14, 0x4b, 0x30, 0x2a, 0x30, 0x6a, 0x30, 0x07, 0xc1, 0xb8, 0x42, 0x22, 0x5c, 0xac, 0x79, 0x89, 190 0x79, 0xf9, 0xc5, 0x12, 0x4c, 0x0a, 0x8c, 0x1a, 0xac, 0x41, 0x10, 0x8e, 0x53, 0x03, 0xe3, 0x8d, 191 0x87, 0x72, 0x0c, 0x1f, 0x1e, 0xca, 0x31, 0xae, 0x78, 0x24, 0xc7, 0x78, 0xe2, 0x91, 0x1c, 0xe3, 192 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0xbe, 0x78, 0x24, 0xc7, 0xf0, 0xe1, 0x91, 0x1c, 193 0xe3, 0x8a, 0xc7, 0x72, 0x8c, 0x27, 0x1e, 0xcb, 0x31, 0x72, 0x09, 0x27, 0xe7, 0xe7, 0xea, 0xa1, 194 0x59, 0xee, 0xc4, 0x07, 0xb7, 0x3a, 0x00, 0x24, 0x14, 0xc0, 0x18, 0xc5, 0x5a, 0x52, 0x59, 0x90, 195 0x5a, 0xfc, 0x83, 0x91, 0x71, 0x11, 0x13, 0xb3, 0x7b, 0x80, 0xd3, 0x2a, 0x26, 0x39, 0x77, 0x88, 196 0x9e, 0x00, 0xa8, 0x1e, 0xbd, 0xf0, 0xd4, 0x9c, 0x1c, 0xef, 0xbc, 0xfc, 0xf2, 0xbc, 0x10, 0x90, 197 0xca, 0x24, 0x36, 0xb0, 0x61, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0b, 0x23, 0x83, 0xdd, 198 0xfa, 0x00, 0x00, 0x00, 199 } 200 201 func (this *Timestamp) Compare(that interface{}) int { 202 if that == nil { 203 if this == nil { 204 return 0 205 } 206 return 1 207 } 208 209 that1, ok := that.(*Timestamp) 210 if !ok { 211 that2, ok := that.(Timestamp) 212 if ok { 213 that1 = &that2 214 } else { 215 return 1 216 } 217 } 218 if that1 == nil { 219 if this == nil { 220 return 0 221 } 222 return 1 223 } else if this == nil { 224 return -1 225 } 226 if this.Seconds != that1.Seconds { 227 if this.Seconds < that1.Seconds { 228 return -1 229 } 230 return 1 231 } 232 if this.Nanos != that1.Nanos { 233 if this.Nanos < that1.Nanos { 234 return -1 235 } 236 return 1 237 } 238 if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 { 239 return c 240 } 241 return 0 242 } 243 func (this *Timestamp) Equal(that interface{}) bool { 244 if that == nil { 245 return this == nil 246 } 247 248 that1, ok := that.(*Timestamp) 249 if !ok { 250 that2, ok := that.(Timestamp) 251 if ok { 252 that1 = &that2 253 } else { 254 return false 255 } 256 } 257 if that1 == nil { 258 return this == nil 259 } else if this == nil { 260 return false 261 } 262 if this.Seconds != that1.Seconds { 263 return false 264 } 265 if this.Nanos != that1.Nanos { 266 return false 267 } 268 if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { 269 return false 270 } 271 return true 272 } 273 func (this *Timestamp) GoString() string { 274 if this == nil { 275 return "nil" 276 } 277 s := make([]string, 0, 6) 278 s = append(s, "&types.Timestamp{") 279 s = append(s, "Seconds: "+fmt.Sprintf("%#v", this.Seconds)+",\n") 280 s = append(s, "Nanos: "+fmt.Sprintf("%#v", this.Nanos)+",\n") 281 if this.XXX_unrecognized != nil { 282 s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") 283 } 284 s = append(s, "}") 285 return strings.Join(s, "") 286 } 287 func valueToGoStringTimestamp(v interface{}, typ string) string { 288 rv := reflect.ValueOf(v) 289 if rv.IsNil() { 290 return "nil" 291 } 292 pv := reflect.Indirect(rv).Interface() 293 return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv) 294 } 295 func (m *Timestamp) Marshal() (dAtA []byte, err error) { 296 size := m.Size() 297 dAtA = make([]byte, size) 298 n, err := m.MarshalToSizedBuffer(dAtA[:size]) 299 if err != nil { 300 return nil, err 301 } 302 return dAtA[:n], nil 303 } 304 305 func (m *Timestamp) MarshalTo(dAtA []byte) (int, error) { 306 size := m.Size() 307 return m.MarshalToSizedBuffer(dAtA[:size]) 308 } 309 310 func (m *Timestamp) MarshalToSizedBuffer(dAtA []byte) (int, error) { 311 i := len(dAtA) 312 _ = i 313 var l int 314 _ = l 315 if m.XXX_unrecognized != nil { 316 i -= len(m.XXX_unrecognized) 317 copy(dAtA[i:], m.XXX_unrecognized) 318 } 319 if m.Nanos != 0 { 320 i = encodeVarintTimestamp(dAtA, i, uint64(m.Nanos)) 321 i-- 322 dAtA[i] = 0x10 323 } 324 if m.Seconds != 0 { 325 i = encodeVarintTimestamp(dAtA, i, uint64(m.Seconds)) 326 i-- 327 dAtA[i] = 0x8 328 } 329 return len(dAtA) - i, nil 330 } 331 332 func encodeVarintTimestamp(dAtA []byte, offset int, v uint64) int { 333 offset -= sovTimestamp(v) 334 base := offset 335 for v >= 1<<7 { 336 dAtA[offset] = uint8(v&0x7f | 0x80) 337 v >>= 7 338 offset++ 339 } 340 dAtA[offset] = uint8(v) 341 return base 342 } 343 func (m *Timestamp) Size() (n int) { 344 if m == nil { 345 return 0 346 } 347 var l int 348 _ = l 349 if m.Seconds != 0 { 350 n += 1 + sovTimestamp(uint64(m.Seconds)) 351 } 352 if m.Nanos != 0 { 353 n += 1 + sovTimestamp(uint64(m.Nanos)) 354 } 355 if m.XXX_unrecognized != nil { 356 n += len(m.XXX_unrecognized) 357 } 358 return n 359 } 360 361 func sovTimestamp(x uint64) (n int) { 362 return (math_bits.Len64(x|1) + 6) / 7 363 } 364 func sozTimestamp(x uint64) (n int) { 365 return sovTimestamp(uint64((x << 1) ^ uint64((int64(x) >> 63)))) 366 } 367 func (m *Timestamp) Unmarshal(dAtA []byte) error { 368 l := len(dAtA) 369 iNdEx := 0 370 for iNdEx < l { 371 preIndex := iNdEx 372 var wire uint64 373 for shift := uint(0); ; shift += 7 { 374 if shift >= 64 { 375 return ErrIntOverflowTimestamp 376 } 377 if iNdEx >= l { 378 return io.ErrUnexpectedEOF 379 } 380 b := dAtA[iNdEx] 381 iNdEx++ 382 wire |= uint64(b&0x7F) << shift 383 if b < 0x80 { 384 break 385 } 386 } 387 fieldNum := int32(wire >> 3) 388 wireType := int(wire & 0x7) 389 if wireType == 4 { 390 return fmt.Errorf("proto: Timestamp: wiretype end group for non-group") 391 } 392 if fieldNum <= 0 { 393 return fmt.Errorf("proto: Timestamp: illegal tag %d (wire type %d)", fieldNum, wire) 394 } 395 switch fieldNum { 396 case 1: 397 if wireType != 0 { 398 return fmt.Errorf("proto: wrong wireType = %d for field Seconds", wireType) 399 } 400 m.Seconds = 0 401 for shift := uint(0); ; shift += 7 { 402 if shift >= 64 { 403 return ErrIntOverflowTimestamp 404 } 405 if iNdEx >= l { 406 return io.ErrUnexpectedEOF 407 } 408 b := dAtA[iNdEx] 409 iNdEx++ 410 m.Seconds |= int64(b&0x7F) << shift 411 if b < 0x80 { 412 break 413 } 414 } 415 case 2: 416 if wireType != 0 { 417 return fmt.Errorf("proto: wrong wireType = %d for field Nanos", wireType) 418 } 419 m.Nanos = 0 420 for shift := uint(0); ; shift += 7 { 421 if shift >= 64 { 422 return ErrIntOverflowTimestamp 423 } 424 if iNdEx >= l { 425 return io.ErrUnexpectedEOF 426 } 427 b := dAtA[iNdEx] 428 iNdEx++ 429 m.Nanos |= int32(b&0x7F) << shift 430 if b < 0x80 { 431 break 432 } 433 } 434 default: 435 iNdEx = preIndex 436 skippy, err := skipTimestamp(dAtA[iNdEx:]) 437 if err != nil { 438 return err 439 } 440 if (skippy < 0) || (iNdEx+skippy) < 0 { 441 return ErrInvalidLengthTimestamp 442 } 443 if (iNdEx + skippy) > l { 444 return io.ErrUnexpectedEOF 445 } 446 m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) 447 iNdEx += skippy 448 } 449 } 450 451 if iNdEx > l { 452 return io.ErrUnexpectedEOF 453 } 454 return nil 455 } 456 func skipTimestamp(dAtA []byte) (n int, err error) { 457 l := len(dAtA) 458 iNdEx := 0 459 depth := 0 460 for iNdEx < l { 461 var wire uint64 462 for shift := uint(0); ; shift += 7 { 463 if shift >= 64 { 464 return 0, ErrIntOverflowTimestamp 465 } 466 if iNdEx >= l { 467 return 0, io.ErrUnexpectedEOF 468 } 469 b := dAtA[iNdEx] 470 iNdEx++ 471 wire |= (uint64(b) & 0x7F) << shift 472 if b < 0x80 { 473 break 474 } 475 } 476 wireType := int(wire & 0x7) 477 switch wireType { 478 case 0: 479 for shift := uint(0); ; shift += 7 { 480 if shift >= 64 { 481 return 0, ErrIntOverflowTimestamp 482 } 483 if iNdEx >= l { 484 return 0, io.ErrUnexpectedEOF 485 } 486 iNdEx++ 487 if dAtA[iNdEx-1] < 0x80 { 488 break 489 } 490 } 491 case 1: 492 iNdEx += 8 493 case 2: 494 var length int 495 for shift := uint(0); ; shift += 7 { 496 if shift >= 64 { 497 return 0, ErrIntOverflowTimestamp 498 } 499 if iNdEx >= l { 500 return 0, io.ErrUnexpectedEOF 501 } 502 b := dAtA[iNdEx] 503 iNdEx++ 504 length |= (int(b) & 0x7F) << shift 505 if b < 0x80 { 506 break 507 } 508 } 509 if length < 0 { 510 return 0, ErrInvalidLengthTimestamp 511 } 512 iNdEx += length 513 case 3: 514 depth++ 515 case 4: 516 if depth == 0 { 517 return 0, ErrUnexpectedEndOfGroupTimestamp 518 } 519 depth-- 520 case 5: 521 iNdEx += 4 522 default: 523 return 0, fmt.Errorf("proto: illegal wireType %d", wireType) 524 } 525 if iNdEx < 0 { 526 return 0, ErrInvalidLengthTimestamp 527 } 528 if depth == 0 { 529 return iNdEx, nil 530 } 531 } 532 return 0, io.ErrUnexpectedEOF 533 } 534 535 var ( 536 ErrInvalidLengthTimestamp = fmt.Errorf("proto: negative length found during unmarshaling") 537 ErrIntOverflowTimestamp = fmt.Errorf("proto: integer overflow") 538 ErrUnexpectedEndOfGroupTimestamp = fmt.Errorf("proto: unexpected end of group") 539 )