timestamp_pb.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. // source: google/protobuf/timestamp.proto
  2. /**
  3. * @fileoverview
  4. * @enhanceable
  5. * @suppress {missingRequire} reports error on implicit type usages.
  6. * @suppress {messageConventions} JS Compiler reports an error if a variable or
  7. * field starts with 'MSG_' and isn't a translatable message.
  8. * @public
  9. */
  10. // GENERATED CODE -- DO NOT EDIT!
  11. /* eslint-disable */
  12. // @ts-nocheck
  13. var jspb = require('google-protobuf');
  14. var goog = jspb;
  15. var global =
  16. (typeof globalThis !== 'undefined' && globalThis) ||
  17. (typeof window !== 'undefined' && window) ||
  18. (typeof global !== 'undefined' && global) ||
  19. (typeof self !== 'undefined' && self) ||
  20. (function () { return this; }).call(null) ||
  21. Function('return this')();
  22. goog.exportSymbol('proto.google.protobuf.Timestamp', null, global);
  23. /**
  24. * Generated by JsPbCodeGenerator.
  25. * @param {Array=} opt_data Optional initial data array, typically from a
  26. * server response, or constructed directly in Javascript. The array is used
  27. * in place and becomes part of the constructed object. It is not cloned.
  28. * If no data is provided, the constructed object will be empty, but still
  29. * valid.
  30. * @extends {jspb.Message}
  31. * @constructor
  32. */
  33. proto.google.protobuf.Timestamp = function(opt_data) {
  34. jspb.Message.initialize(this, opt_data, 0, -1, null, null);
  35. };
  36. goog.inherits(proto.google.protobuf.Timestamp, jspb.Message);
  37. if (goog.DEBUG && !COMPILED) {
  38. /**
  39. * @public
  40. * @override
  41. */
  42. proto.google.protobuf.Timestamp.displayName = 'proto.google.protobuf.Timestamp';
  43. }
  44. if (jspb.Message.GENERATE_TO_OBJECT) {
  45. /**
  46. * Creates an object representation of this proto.
  47. * Field names that are reserved in JavaScript and will be renamed to pb_name.
  48. * Optional fields that are not set will be set to undefined.
  49. * To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
  50. * For the list of reserved names please see:
  51. * net/proto2/compiler/js/internal/generator.cc#kKeyword.
  52. * @param {boolean=} opt_includeInstance Deprecated. whether to include the
  53. * JSPB instance for transitional soy proto support:
  54. * http://goto/soy-param-migration
  55. * @return {!Object}
  56. */
  57. proto.google.protobuf.Timestamp.prototype.toObject = function(opt_includeInstance) {
  58. return proto.google.protobuf.Timestamp.toObject(opt_includeInstance, this);
  59. };
  60. /**
  61. * Static version of the {@see toObject} method.
  62. * @param {boolean|undefined} includeInstance Deprecated. Whether to include
  63. * the JSPB instance for transitional soy proto support:
  64. * http://goto/soy-param-migration
  65. * @param {!proto.google.protobuf.Timestamp} msg The msg instance to transform.
  66. * @return {!Object}
  67. * @suppress {unusedLocalVariables} f is only used for nested messages
  68. */
  69. proto.google.protobuf.Timestamp.toObject = function(includeInstance, msg) {
  70. var f, obj = {
  71. seconds: jspb.Message.getFieldWithDefault(msg, 1, 0),
  72. nanos: jspb.Message.getFieldWithDefault(msg, 2, 0)
  73. };
  74. if (includeInstance) {
  75. obj.$jspbMessageInstance = msg;
  76. }
  77. return obj;
  78. };
  79. }
  80. /**
  81. * Deserializes binary data (in protobuf wire format).
  82. * @param {jspb.ByteSource} bytes The bytes to deserialize.
  83. * @return {!proto.google.protobuf.Timestamp}
  84. */
  85. proto.google.protobuf.Timestamp.deserializeBinary = function(bytes) {
  86. var reader = new jspb.BinaryReader(bytes);
  87. var msg = new proto.google.protobuf.Timestamp;
  88. return proto.google.protobuf.Timestamp.deserializeBinaryFromReader(msg, reader);
  89. };
  90. /**
  91. * Deserializes binary data (in protobuf wire format) from the
  92. * given reader into the given message object.
  93. * @param {!proto.google.protobuf.Timestamp} msg The message object to deserialize into.
  94. * @param {!jspb.BinaryReader} reader The BinaryReader to use.
  95. * @return {!proto.google.protobuf.Timestamp}
  96. */
  97. proto.google.protobuf.Timestamp.deserializeBinaryFromReader = function(msg, reader) {
  98. while (reader.nextField()) {
  99. if (reader.isEndGroup()) {
  100. break;
  101. }
  102. var field = reader.getFieldNumber();
  103. switch (field) {
  104. case 1:
  105. var value = /** @type {number} */ (reader.readInt64());
  106. msg.setSeconds(value);
  107. break;
  108. case 2:
  109. var value = /** @type {number} */ (reader.readInt32());
  110. msg.setNanos(value);
  111. break;
  112. default:
  113. reader.skipField();
  114. break;
  115. }
  116. }
  117. return msg;
  118. };
  119. /**
  120. * Serializes the message to binary data (in protobuf wire format).
  121. * @return {!Uint8Array}
  122. */
  123. proto.google.protobuf.Timestamp.prototype.serializeBinary = function() {
  124. var writer = new jspb.BinaryWriter();
  125. proto.google.protobuf.Timestamp.serializeBinaryToWriter(this, writer);
  126. return writer.getResultBuffer();
  127. };
  128. /**
  129. * Serializes the given message to binary data (in protobuf wire
  130. * format), writing to the given BinaryWriter.
  131. * @param {!proto.google.protobuf.Timestamp} message
  132. * @param {!jspb.BinaryWriter} writer
  133. * @suppress {unusedLocalVariables} f is only used for nested messages
  134. */
  135. proto.google.protobuf.Timestamp.serializeBinaryToWriter = function(message, writer) {
  136. var f = undefined;
  137. f = message.getSeconds();
  138. if (f !== 0) {
  139. writer.writeInt64(
  140. 1,
  141. f
  142. );
  143. }
  144. f = message.getNanos();
  145. if (f !== 0) {
  146. writer.writeInt32(
  147. 2,
  148. f
  149. );
  150. }
  151. };
  152. /**
  153. * optional int64 seconds = 1;
  154. * @return {number}
  155. */
  156. proto.google.protobuf.Timestamp.prototype.getSeconds = function() {
  157. return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0));
  158. };
  159. /**
  160. * @param {number} value
  161. * @return {!proto.google.protobuf.Timestamp} returns this
  162. */
  163. proto.google.protobuf.Timestamp.prototype.setSeconds = function(value) {
  164. return jspb.Message.setProto3IntField(this, 1, value);
  165. };
  166. /**
  167. * optional int32 nanos = 2;
  168. * @return {number}
  169. */
  170. proto.google.protobuf.Timestamp.prototype.getNanos = function() {
  171. return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0));
  172. };
  173. /**
  174. * @param {number} value
  175. * @return {!proto.google.protobuf.Timestamp} returns this
  176. */
  177. proto.google.protobuf.Timestamp.prototype.setNanos = function(value) {
  178. return jspb.Message.setProto3IntField(this, 2, value);
  179. };
  180. goog.object.extend(exports, proto.google.protobuf);
  181. /* This code will be inserted into generated code for
  182. * google/protobuf/timestamp.proto. */
  183. /**
  184. * Returns a JavaScript 'Date' object corresponding to this Timestamp.
  185. * @return {!Date}
  186. */
  187. proto.google.protobuf.Timestamp.prototype.toDate = function() {
  188. var seconds = this.getSeconds();
  189. var nanos = this.getNanos();
  190. return new Date((seconds * 1000) + (nanos / 1000000));
  191. };
  192. /**
  193. * Sets the value of this Timestamp object to be the given Date.
  194. * @param {!Date} value The value to set.
  195. */
  196. proto.google.protobuf.Timestamp.prototype.fromDate = function(value) {
  197. this.setSeconds(Math.floor(value.getTime() / 1000));
  198. this.setNanos(value.getMilliseconds() * 1000000);
  199. };
  200. /**
  201. * Factory method that returns a Timestamp object with value equal to
  202. * the given Date.
  203. * @param {!Date} value The value to set.
  204. * @return {!proto.google.protobuf.Timestamp}
  205. */
  206. proto.google.protobuf.Timestamp.fromDate = function(value) {
  207. var timestamp = new proto.google.protobuf.Timestamp();
  208. timestamp.fromDate(value);
  209. return timestamp;
  210. };