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