123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375(********************************************************)(* AUTOGENERATED FILE - DO NOT EDIT! *)(********************************************************)(* Generated by: ocaml-protoc-plugin *)(* https://github.com/andersfugmann/ocaml-protoc-plugin *)(********************************************************)(*
Source: google/protobuf/timestamp.proto
Syntax: proto3
Parameters:
debug=false
annot=''
opens=[]
int64_as_int=true
int32_as_int=true
fixed_as_int=false
singleton_record=false
prefix_output_with_package=false
*)[@@@ocaml.alert"-protobuf"](* Disable deprecation warnings for protobuf*)(**/**)moduleRuntime'=Ocaml_protoc_plugin[@@warning"-33"]moduleImported'modules=structend(**/**)modulerecGoogle:sigmodulerecProtobuf:sig(**
{%html:
<p>A Timestamp represents a point in time independent of any time zone or local
calendar, encoded as a count of seconds and fractions of seconds at
nanosecond resolution. The count is relative to an epoch at UTC midnight on
January 1, 1970, in the proleptic Gregorian calendar which extends the
Gregorian calendar backwards to year one.</p>
<p>All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
second table is needed for interpretation, using a <a href="https://developers.google.com/time/smear">24-hour linear
smear</a>.</p>
<p>The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
restricting to that range, we ensure that we can convert to and from <a href="https://www.ietf.org/rfc/rfc3339.txt">RFC
3339</a> date strings.</p>
<h1 id="examples">Examples</h1>
<p>Example 1: Compute Timestamp from POSIX <code>time()</code>.</p>
<pre><code> Timestamp timestamp;
timestamp.set_seconds(time(NULL));
timestamp.set_nanos(0);
</code></pre>
<p>Example 2: Compute Timestamp from POSIX <code>gettimeofday()</code>.</p>
<pre><code> struct timeval tv;
gettimeofday(&tv, NULL);
Timestamp timestamp;
timestamp.set_seconds(tv.tv_sec);
timestamp.set_nanos(tv.tv_usec * 1000);
</code></pre>
<p>Example 3: Compute Timestamp from Win32 <code>GetSystemTimeAsFileTime()</code>.</p>
<pre><code> FILETIME ft;
GetSystemTimeAsFileTime(&ft);
UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
</code></pre>
<p>A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.</p>
<pre><code> Timestamp timestamp;
timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
</code></pre>
<p>Example 4: Compute Timestamp from Java <code>System.currentTimeMillis()</code>.</p>
<pre><code> long millis = System.currentTimeMillis();
Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
.setNanos((int) ((millis % 1000) * 1000000)).build();
</code></pre>
<p>Example 5: Compute Timestamp from Java <code>Instant.now()</code>.</p>
<pre><code> Instant now = Instant.now();
Timestamp timestamp =
Timestamp.newBuilder().setSeconds(now.getEpochSecond())
.setNanos(now.getNano()).build();
</code></pre>
<p>Example 6: Compute Timestamp from current time in Python.</p>
<pre><code> timestamp = Timestamp()
timestamp.GetCurrentTime()
</code></pre>
<h1 id="json-mapping">JSON Mapping</h1>
<p>In JSON format, the Timestamp type is encoded as a string in the
<a href="https://www.ietf.org/rfc/rfc3339.txt">RFC 3339</a> format. That is, the
format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
where {year} is always expressed using four digits while {month}, {day},
{hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
is required. A ProtoJSON serializer should always use UTC (as indicated by
"Z") when printing the Timestamp type and a ProtoJSON parser should be
able to accept both UTC and other timezones (as indicated by an offset).</p>
<p>For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
01:30 UTC on January 15, 2017.</p>
<p>In JavaScript, one can convert a Date object to this format using the
standard
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString">toISOString()</a>
method. In Python, a standard <code>datetime.datetime</code> object can be converted
to this format using
<a href="https://docs.python.org/2/library/time.html#time.strftime"><code>strftime</code></a> with
the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
the Joda Time's <a href="http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()"><code>ISODateTimeFormat.dateTime()</code></a> to obtain a formatter capable of generating timestamps in this format.</p>
%}
*)modulerecTimestamp:sigtypet={seconds:int;(**
{%html:
<p>Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must
be between -62135596800 and 253402300799 inclusive (which corresponds to
0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z).</p>
%}
*)nanos:int;(**
{%html:
<p>Non-negative fractions of a second at nanosecond resolution. This field is
the nanosecond portion of the duration, not an alternative to seconds.
Negative second values with fractions must still have non-negative nanos
values that count forward in time. Must be between 0 and 999,999,999
inclusive.</p>
%}
*)}valmake:?seconds:int->?nanos:int->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?seconds:int->?nanos:int->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)endendend=structmodulerecProtobuf:sig(**
{%html:
<p>A Timestamp represents a point in time independent of any time zone or local
calendar, encoded as a count of seconds and fractions of seconds at
nanosecond resolution. The count is relative to an epoch at UTC midnight on
January 1, 1970, in the proleptic Gregorian calendar which extends the
Gregorian calendar backwards to year one.</p>
<p>All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
second table is needed for interpretation, using a <a href="https://developers.google.com/time/smear">24-hour linear
smear</a>.</p>
<p>The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
restricting to that range, we ensure that we can convert to and from <a href="https://www.ietf.org/rfc/rfc3339.txt">RFC
3339</a> date strings.</p>
<h1 id="examples">Examples</h1>
<p>Example 1: Compute Timestamp from POSIX <code>time()</code>.</p>
<pre><code> Timestamp timestamp;
timestamp.set_seconds(time(NULL));
timestamp.set_nanos(0);
</code></pre>
<p>Example 2: Compute Timestamp from POSIX <code>gettimeofday()</code>.</p>
<pre><code> struct timeval tv;
gettimeofday(&tv, NULL);
Timestamp timestamp;
timestamp.set_seconds(tv.tv_sec);
timestamp.set_nanos(tv.tv_usec * 1000);
</code></pre>
<p>Example 3: Compute Timestamp from Win32 <code>GetSystemTimeAsFileTime()</code>.</p>
<pre><code> FILETIME ft;
GetSystemTimeAsFileTime(&ft);
UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
</code></pre>
<p>A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.</p>
<pre><code> Timestamp timestamp;
timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
</code></pre>
<p>Example 4: Compute Timestamp from Java <code>System.currentTimeMillis()</code>.</p>
<pre><code> long millis = System.currentTimeMillis();
Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
.setNanos((int) ((millis % 1000) * 1000000)).build();
</code></pre>
<p>Example 5: Compute Timestamp from Java <code>Instant.now()</code>.</p>
<pre><code> Instant now = Instant.now();
Timestamp timestamp =
Timestamp.newBuilder().setSeconds(now.getEpochSecond())
.setNanos(now.getNano()).build();
</code></pre>
<p>Example 6: Compute Timestamp from current time in Python.</p>
<pre><code> timestamp = Timestamp()
timestamp.GetCurrentTime()
</code></pre>
<h1 id="json-mapping">JSON Mapping</h1>
<p>In JSON format, the Timestamp type is encoded as a string in the
<a href="https://www.ietf.org/rfc/rfc3339.txt">RFC 3339</a> format. That is, the
format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
where {year} is always expressed using four digits while {month}, {day},
{hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
is required. A ProtoJSON serializer should always use UTC (as indicated by
"Z") when printing the Timestamp type and a ProtoJSON parser should be
able to accept both UTC and other timezones (as indicated by an offset).</p>
<p>For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
01:30 UTC on January 15, 2017.</p>
<p>In JavaScript, one can convert a Date object to this format using the
standard
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString">toISOString()</a>
method. In Python, a standard <code>datetime.datetime</code> object can be converted
to this format using
<a href="https://docs.python.org/2/library/time.html#time.strftime"><code>strftime</code></a> with
the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
the Joda Time's <a href="http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()"><code>ISODateTimeFormat.dateTime()</code></a> to obtain a formatter capable of generating timestamps in this format.</p>
%}
*)modulerecTimestamp:sigtypet={seconds:int;(**
{%html:
<p>Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must
be between -62135596800 and 253402300799 inclusive (which corresponds to
0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z).</p>
%}
*)nanos:int;(**
{%html:
<p>Non-negative fractions of a second at nanosecond resolution. This field is
the nanosecond portion of the duration, not an alternative to seconds.
Negative second values with fractions must still have non-negative nanos
values that count forward in time. Must be between 0 and 999,999,999
inclusive.</p>
%}
*)}valmake:?seconds:int->?nanos:int->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?seconds:int->?nanos:int->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)endend=structmodulerecTimestamp:sigtypet={seconds:int;(**
{%html:
<p>Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must
be between -62135596800 and 253402300799 inclusive (which corresponds to
0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z).</p>
%}
*)nanos:int;(**
{%html:
<p>Non-negative fractions of a second at nanosecond resolution. This field is
the nanosecond portion of the duration, not an alternative to seconds.
Negative second values with fractions must still have non-negative nanos
values that count forward in time. Must be between 0 and 999,999,999
inclusive.</p>
%}
*)}valmake:?seconds:int->?nanos:int->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?seconds:int->?nanos:int->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end=structmoduleThis'_=Timestampletname()=".google.protobuf.Timestamp"typet={seconds:int;nanos:int;}typemake_t=?seconds:int->?nanos:int->unit->tletmake?(seconds=0)?(nanos=0)()={seconds;nanos}letmerge=letmerge_seconds=Runtime'.Merge.mergeRuntime'.Spec.(basic((1,"seconds","seconds"),int64_int,(0)))inletmerge_nanos=Runtime'.Merge.mergeRuntime'.Spec.(basic((2,"nanos","nanos"),int32_int,(0)))infunt1t2->{seconds=(merge_secondst1.secondst2.seconds);nanos=(merge_nanost1.nanost2.nanos);}letspec()=Runtime'.Spec.(basic((1,"seconds","seconds"),int64_int,(0))^::basic((2,"nanos","nanos"),int32_int,(0))^::nil)letto_proto'=letserialize=Runtime'.apply_lazy(fun()->Runtime'.Serialize.serialize(spec()))infunwriter{seconds;nanos}->serializewritersecondsnanosletto_protot=letwriter=Runtime'.Writer.init()into_proto'writert;writerletfrom_proto_exn=letconstructorsecondsnanos={seconds;nanos}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize.deserialize(spec())constructor)letfrom_protowriter=Runtime'.Result.catch(fun()->from_proto_exnwriter)letto_jsonoptions=letserialize=Runtime'.Serialize_json.serialize~message_name:(name())(spec())optionsinfun{seconds;nanos}->serializesecondsnanosletfrom_json_exn=letconstructorsecondsnanos={seconds;nanos}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize_json.deserialize~message_name:(name())(spec())constructor)letfrom_jsonjson=Runtime'.Result.catch(fun()->from_json_exnjson)endendend