Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Unified Diff: third_party/protobuf/src/google/protobuf/compiler/js/well_known_types/timestamp.js

Issue 2495533002: third_party/protobuf: Update to HEAD (83d681ee2c) (Closed)
Patch Set: Make chrome settings proto generated file a component Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/protobuf/src/google/protobuf/compiler/js/well_known_types/timestamp.js
diff --git a/third_party/protobuf/src/google/protobuf/compiler/ruby/ruby_generator.h b/third_party/protobuf/src/google/protobuf/compiler/js/well_known_types/timestamp.js
similarity index 70%
copy from third_party/protobuf/src/google/protobuf/compiler/ruby/ruby_generator.h
copy to third_party/protobuf/src/google/protobuf/compiler/js/well_known_types/timestamp.js
index 75555c31b59917ea5630361e39cefa3a314eb99d..77c07bb4e1a1e118d27b6f098a0cee2d575b8cfe 100644
--- a/third_party/protobuf/src/google/protobuf/compiler/ruby/ruby_generator.h
+++ b/third_party/protobuf/src/google/protobuf/compiler/js/well_known_types/timestamp.js
@@ -28,31 +28,27 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#ifndef GOOGLE_PROTOBUF_COMPILER_RUBY_GENERATOR_H__
-#define GOOGLE_PROTOBUF_COMPILER_RUBY_GENERATOR_H__
-
-#include <string>
-
-#include <google/protobuf/compiler/code_generator.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace ruby {
-
-class LIBPROTOC_EXPORT Generator
- : public google::protobuf::compiler::CodeGenerator {
- virtual bool Generate(
- const FileDescriptor* file,
- const string& parameter,
- GeneratorContext* generator_context,
- string* error) const;
+/* This code will be inserted into generated code for
+ * google/protobuf/timestamp.proto. */
+
+/**
+ * Returns a JavaScript 'Date' object corresponding to this Timestamp.
+ * @return {!Date}
+ */
+proto.google.protobuf.Timestamp.prototype.toDate = function() {
+ var seconds = this.getSeconds();
+ var nanos = this.getNanos();
+
+ return new Date((seconds * 1000) + (nanos / 1000000));
};
-} // namespace ruby
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_RUBY_GENERATOR_H__
+/**
+ * Sets the value of this Timestamp object to be the given Date.
+ * @param {!Date} value The value to set.
+ */
+proto.google.protobuf.Timestamp.prototype.fromDate = function(value) {
+ var millis = value.getTime();
+ this.setSeconds(Math.floor(value.getTime() / 1000));
+ this.setNanos(value.getMilliseconds() * 1000000);
+};

Powered by Google App Engine
This is Rietveld 408576698