[Groonga-commit] droonga/express-droonga at 9039ce3 [master] Fill the "date" field of generated messages in microseconds.

Back to archive index

YUKI Hiroshi null+****@clear*****
Wed Apr 8 15:42:50 JST 2015


YUKI Hiroshi	2015-04-08 15:42:50 +0900 (Wed, 08 Apr 2015)

  New Revision: 9039ce3b64a0fd644d6183e465b5ea8119737711
  https://github.com/droonga/express-droonga/commit/9039ce3b64a0fd644d6183e465b5ea8119737711

  Message:
    Fill the "date" field of generated messages in microseconds.

  Modified files:
    lib/droonga-protocol/connection.js
    package.json

  Modified: lib/droonga-protocol/connection.js (+11 -1)
===================================================================
--- lib/droonga-protocol/connection.js    2015-04-07 17:28:37 +0900 (a4ea33a)
+++ lib/droonga-protocol/connection.js    2015-04-08 15:42:50 +0900 (84f678d)
@@ -11,6 +11,7 @@ var util = require('util');
 var EventEmitter = require('events').EventEmitter;
 var fluent = require('fluent-logger');
 var Q = require('q');
+var microtime = require('microtime');
 
 var FluentReceiver = require('./receiver').FluentReceiver;
 var ConsoleLogger = require('../console-logger').ConsoleLogger;
@@ -170,7 +171,16 @@ function getCurrentTime() {
   // The method toISOString() returns a GMT (ex. 2013-01-10T08:34:41.252Z)
   // on node. However, a local time (ex. 2013-01-10T17:34:41.252+09:00) is
   // more helpful for debugging. We should use it in the feature...
-  return new Date().toISOString();
+
+  var nowStruct = microtime.nowStruct();
+  var seconds = nowStruct[0];
+  var microseconds = nowStruct[1];
+
+  var date = new Date((seconds * 1000) + (microseconds / 1000));
+  var isoString = date.toISOString();
+  var subsecondsPart = ('000000' + microseconds).substr(-6);
+  var isoStringWithMicroseconds = isoString.replace(/\.\d+Z$/, '.' + subsecondsPart + 'Z');
+  return isoStringWithMicroseconds;
 }
 
 function toPositiveInteger(number) {

  Modified: package.json (+1 -0)
===================================================================
--- package.json    2015-04-07 17:28:37 +0900 (bdde980)
+++ package.json    2015-04-08 15:42:50 +0900 (0f93b10)
@@ -32,6 +32,7 @@
     "less-middleware": ">=0.2",
     "uber-cache": ">=2.0.0",
     "method-override": "*",
+    "microtime": "*",
     "msgpack": "*",
     "q": "*",
     "serf-rpc": "*",
-------------- next part --------------
HTML����������������������������...
Descargar 



More information about the Groonga-commit mailing list
Back to archive index