aboutsummaryrefslogtreecommitdiffhomepage
path: root/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs
diff options
context:
space:
mode:
Diffstat (limited to 'csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs')
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs25
1 files changed, 25 insertions, 0 deletions
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs
index b789f6da..911f797e 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs
@@ -51,6 +51,8 @@ namespace Google.Protobuf.WellKnownTypes {
/// and from RFC 3339 date strings.
/// See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt).
///
+ /// # Examples
+ ///
/// Example 1: Compute Timestamp from POSIX `time()`.
///
/// Timestamp timestamp;
@@ -89,6 +91,29 @@ namespace Google.Protobuf.WellKnownTypes {
///
/// timestamp = Timestamp()
/// timestamp.GetCurrentTime()
+ ///
+ /// # JSON Mapping
+ ///
+ /// In JSON format, the Timestamp type is encoded as a string in the
+ /// [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) 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, though only UTC (as indicated by "Z") is presently supported.
+ ///
+ /// For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
+ /// 01:30 UTC on January 15, 2017.
+ ///
+ /// In JavaScript, one can convert a Date object to this format using the
+ /// standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString]
+ /// method. In Python, a standard `datetime.datetime` object can be converted
+ /// to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime)
+ /// with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one
+ /// can use the Joda Time's [`ISODateTimeFormat.dateTime()`](
+ /// http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime())
+ /// to obtain a formatter capable of generating timestamps in this format.
/// </summary>
public sealed partial class Timestamp : pb::IMessage<Timestamp> {
private static readonly pb::MessageParser<Timestamp> _parser = new pb::MessageParser<Timestamp>(() => new Timestamp());