OLD | NEW |
1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
4 // | 4 // |
5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
7 // met: | 7 // met: |
8 // | 8 // |
9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
(...skipping 10 matching lines...) Expand all Loading... |
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 | 30 |
31 // Defines utilities for the Timestamp and Duration well known types. | |
32 | |
33 #ifndef GOOGLE_PROTOBUF_UTIL_TIME_UTIL_H__ | 31 #ifndef GOOGLE_PROTOBUF_UTIL_TIME_UTIL_H__ |
34 #define GOOGLE_PROTOBUF_UTIL_TIME_UTIL_H__ | 32 #define GOOGLE_PROTOBUF_UTIL_TIME_UTIL_H__ |
35 | 33 |
36 #include <ctime> | 34 #include <ctime> |
37 #include <ostream> | 35 #include <ostream> |
38 #include <string> | 36 #include <string> |
39 #ifdef _MSC_VER | 37 #ifdef _MSC_VER |
40 #include <winsock2.h> | 38 #include <winsock2.h> |
41 #else | 39 #else |
42 #include <sys/time.h> | 40 #include <sys/time.h> |
43 #endif | 41 #endif |
44 | 42 |
45 #include <google/protobuf/duration.pb.h> | 43 #include <google/protobuf/duration.pb.h> |
46 #include <google/protobuf/timestamp.pb.h> | 44 #include <google/protobuf/timestamp.pb.h> |
47 | 45 |
48 namespace google { | 46 namespace google { |
49 namespace protobuf { | 47 namespace protobuf { |
50 namespace util { | 48 namespace util { |
51 | 49 |
52 // Utility functions for Timestamp and Duration. | |
53 class LIBPROTOBUF_EXPORT TimeUtil { | 50 class LIBPROTOBUF_EXPORT TimeUtil { |
54 typedef google::protobuf::Timestamp Timestamp; | 51 typedef google::protobuf::Timestamp Timestamp; |
55 typedef google::protobuf::Duration Duration; | 52 typedef google::protobuf::Duration Duration; |
56 | 53 |
57 public: | 54 public: |
58 // The min/max Timestamp/Duration values we support. | 55 // The min/max Timestamp/Duration values we support. |
59 // | 56 // |
60 // For "0001-01-01T00:00:00Z". | 57 // For "0001-01-01T00:00:00Z". |
61 static const int64 kTimestampMinSeconds = -62135596800LL; | 58 static const int64 kTimestampMinSeconds = -62135596800LL; |
62 // For "9999-12-31T23:59:59.999999999Z". | 59 // For "9999-12-31T23:59:59.999999999Z". |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 inline ostream& operator<<(ostream& out, const Timestamp& t) { | 284 inline ostream& operator<<(ostream& out, const Timestamp& t) { |
288 out << google::protobuf::util::TimeUtil::ToString(t); | 285 out << google::protobuf::util::TimeUtil::ToString(t); |
289 return out; | 286 return out; |
290 } | 287 } |
291 | 288 |
292 } // namespace protobuf | 289 } // namespace protobuf |
293 | 290 |
294 | 291 |
295 } // namespace google | 292 } // namespace google |
296 #endif // GOOGLE_PROTOBUF_UTIL_TIME_UTIL_H__ | 293 #endif // GOOGLE_PROTOBUF_UTIL_TIME_UTIL_H__ |
OLD | NEW |