Comparing version 0.0.3 to 0.0.4
0.0.4 / 2013-04-16 | ||
================== | ||
* add accessLogDate() | ||
0.0.3 / 2013-03-06 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -109,1 +109,15 @@ /*! | ||
}; | ||
/** | ||
* Access log format date. format: `moment().format('DD/MMM/YYYY:HH:mm:ss ZZ')` | ||
* | ||
* @return {String} | ||
*/ | ||
exports.accessLogDate = function () { | ||
// 0 1 2 3 4 5 6 | ||
// Tue Apr 16 2013 16:40:09 GMT+0800 (CST) | ||
// => | ||
// 16/Apr/2013:16:40:09 +0800 | ||
var dates = new Date().toString().split(' '); | ||
return dates[2] + '/' + dates[1] + '/' + dates[3] + ':' + dates[4] + ' ' + dates[5].substring(3); | ||
}; |
{ | ||
"name": "utility", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "A collection of useful utilities.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -45,4 +45,28 @@ utility [![Build Status](https://secure.travis-ci.org/fengmk2/utility.png)](http://travis-ci.org/fengmk2/utility) | ||
utils.escape('<script/>"& &'); // '<script/>"& &' | ||
// accessLogDate | ||
utils.accessLogDate(); // '16/Apr/2013:16:40:09 +0800' | ||
``` | ||
## accessLogDate() benchmark | ||
[benchmark/date_format.js](https://github.com/fengmk2/fengmk2.github.com/blob/master/benchmark/date_format.js) | ||
```bash | ||
$ node benchmark/date_format.js | ||
moment().format(): "16/Apr/2013:18:18:30 +0800" | ||
new Date().toString(): "Tue Apr 16 2013 18:18:30 GMT+0800 (CST)" | ||
Date(): "Tue Apr 16 2013 18:18:30 GMT+0800 (CST)" | ||
fasterAccessDate(): "16/Apr/2013:18:18:30 +0800" | ||
fasterAccessDate2(): "16/Apr/2013:18:18:30 +0800" | ||
------------------------ | ||
moment().format('DD/MMM/YYYY:HH:mm:ss ZZ') x 78,364 ops/sec ±1.01% (99 runs sampled) | ||
new Date().toString() x 837,714 ops/sec ±0.92% (95 runs sampled) | ||
Date() x 777,068 ops/sec ±4.76% (90 runs sampled) | ||
fasterAccessDate() x 337,151 ops/sec ±1.51% (95 runs sampled) | ||
fasterAccessDate2() x 335,866 ops/sec ±2.27% (92 runs sampled) | ||
Fastest is new Date().toString() | ||
``` | ||
## License | ||
@@ -49,0 +73,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8394
112
94