@@ -21,92 +21,6 @@ class EnvironmentActivitySignalParam(TypedDict, total=False):
21
21
22
22
timestamp : Annotated [Union [str , datetime ], PropertyInfo (format = "iso8601" )]
23
23
"""
24
- A Timestamp represents a point in time independent of any time zone or local
25
- calendar, encoded as a count of seconds and fractions of seconds at nanosecond
26
- resolution. The count is relative to an epoch at UTC midnight on January 1,
27
- 1970, in the proleptic Gregorian calendar which extends the Gregorian calendar
28
- backwards to year one.
29
-
30
- All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
31
- second table is needed for interpretation, using a
32
- [24-hour linear smear](https://developers.google.com/time/smear).
33
-
34
- The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
35
- restricting to that range, we ensure that we can convert to and from
36
- [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
37
-
38
- # Examples
39
-
40
- Example 1: Compute Timestamp from POSIX `time()`.
41
-
42
- Timestamp timestamp;
43
- timestamp.set_seconds(time(NULL));
44
- timestamp.set_nanos(0);
45
-
46
- Example 2: Compute Timestamp from POSIX `gettimeofday()`.
47
-
48
- struct timeval tv;
49
- gettimeofday(&tv, NULL);
50
-
51
- Timestamp timestamp;
52
- timestamp.set_seconds(tv.tv_sec);
53
- timestamp.set_nanos(tv.tv_usec * 1000);
54
-
55
- Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
56
-
57
- FILETIME ft;
58
- GetSystemTimeAsFileTime(&ft);
59
- UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
60
-
61
- // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
62
- // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
63
- Timestamp timestamp;
64
- timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
65
- timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
66
-
67
- Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
68
-
69
- long millis = System.currentTimeMillis();
70
-
71
- Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
72
- .setNanos((int) ((millis % 1000) * 1000000)).build();
73
-
74
- Example 5: Compute Timestamp from Java `Instant.now()`.
75
-
76
- Instant now = Instant.now();
77
-
78
- Timestamp timestamp =
79
- Timestamp.newBuilder().setSeconds(now.getEpochSecond())
80
- .setNanos(now.getNano()).build();
81
-
82
- Example 6: Compute Timestamp from current time in Python.
83
-
84
- timestamp = Timestamp()
85
- timestamp.GetCurrentTime()
86
-
87
- # JSON Mapping
88
-
89
- In JSON format, the Timestamp type is encoded as a string in the
90
- [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the format is
91
- "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" where {year} is always
92
- expressed using four digits while {month}, {day}, {hour}, {min}, and {sec} are
93
- zero-padded to two digits each. The fractional seconds, which can go up to 9
94
- digits (i.e. up to 1 nanosecond resolution), are optional. The "Z" suffix
95
- indicates the timezone ("UTC"); the timezone is required. A proto3 JSON
96
- serializer should always use UTC (as indicated by "Z") when printing the
97
- Timestamp type and a proto3 JSON parser should be able to accept both UTC and
98
- other timezones (as indicated by an offset).
99
-
100
- For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past 01:30 UTC on
101
- January 15, 2017.
102
-
103
- In JavaScript, one can convert a Date object to this format using the standard
104
- [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
105
- method. In Python, a standard `datetime.datetime` object can be converted to
106
- this format using
107
- [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with the
108
- time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use the
109
- Joda Time's
110
- [`ISODateTimeFormat.dateTime()`](<http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()>)
111
- to obtain a formatter capable of generating timestamps in this format.
24
+ timestamp of when the activity was observed by the source. Only reported every 5
25
+ minutes. Zero value means no activity was observed.
112
26
"""
0 commit comments