time-stamp
Advanced tools
Comparing version 0.1.0 to 0.1.1
32
index.js
@@ -10,9 +10,3 @@ /*! | ||
var pad = require('pad-left'); | ||
/** | ||
* Expose `timestamp` | ||
*/ | ||
/** | ||
* Parse the given pattern and return a formatted | ||
@@ -33,8 +27,8 @@ * timestamp. | ||
return pattern.replace(/([YMDHms]{2,4})(:\/)?/g, function (_, key, sep) { | ||
var time = method(key); | ||
if (!time) return _; | ||
var increment = method(key); | ||
if (!increment) return _; | ||
sep = sep || ''; | ||
var res = date[time]().toString(); | ||
var diff = key.length - res.length; | ||
return pad(res, diff, 0) + (sep || ''); | ||
var res = '00' + date[increment[0]]().toString(); | ||
return res.slice(-increment[1]) + sep; | ||
}); | ||
@@ -45,11 +39,11 @@ }; | ||
return ({ | ||
YYYY: 'getFullYear', | ||
YY: 'getFullYear', | ||
MM: 'getMonth', | ||
DD: 'getDate', | ||
HH: 'getHours', | ||
mm: 'getMinutes', | ||
ss: 'getSeconds', | ||
ms: 'getMilliseconds' | ||
YYYY: ['getFullYear', 4], | ||
YY: ['getFullYear', 2], | ||
MM: ['getMonth', 2], | ||
DD: ['getDate', 2], | ||
HH: ['getHours', 2], | ||
mm: ['getMinutes', 2], | ||
ss: ['getSeconds', 2], | ||
ms: ['getMilliseconds', 3] | ||
})[key]; | ||
} |
{ | ||
"name": "time-stamp", | ||
"description": "Get a formatted timestamp.", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"homepage": "https://github.com/jonschlinkert/time-stamp", | ||
"author": { | ||
"name": "Jon Schlinkert", | ||
"url": "https://github.com/jonschlinkert" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/jonschlinkert/time-stamp.git" | ||
}, | ||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"repository": "jonschlinkert/time-stamp", | ||
"bugs": { | ||
"url": "https://github.com/jonschlinkert/time-stamp/issues" | ||
}, | ||
"license": { | ||
"type": "MIT", | ||
"url": "https://github.com/jonschlinkert/time-stamp/blob/master/LICENSE" | ||
}, | ||
"license": "MIT", | ||
"files": [ | ||
@@ -31,5 +22,2 @@ "index.js" | ||
}, | ||
"dependencies": { | ||
"pad-left": "^1.0.1" | ||
}, | ||
"devDependencies": { | ||
@@ -39,3 +27,29 @@ "mocha": "*", | ||
}, | ||
"keywords": [] | ||
"keywords": [ | ||
"console", | ||
"date", | ||
"format", | ||
"formatting", | ||
"log", | ||
"pretty", | ||
"stamp", | ||
"terminal", | ||
"time", | ||
"time-stamp" | ||
], | ||
"verb": { | ||
"related": { | ||
"list": [ | ||
"days", | ||
"iso-week", | ||
"month", | ||
"months", | ||
"o-clock", | ||
"seconds", | ||
"week", | ||
"weekday", | ||
"year" | ||
] | ||
} | ||
} | ||
} |
@@ -5,6 +5,6 @@ # time-stamp [![NPM version](https://badge.fury.io/js/time-stamp.svg)](http://badge.fury.io/js/time-stamp) | ||
## Install with [npm](npmjs.org) | ||
Install with [npm](https://www.npmjs.com/) | ||
```bash | ||
npm i time-stamp --save | ||
```sh | ||
$ npm i time-stamp --save | ||
``` | ||
@@ -17,2 +17,5 @@ | ||
timestamp(); | ||
//=> '2015:04:01' | ||
timestamp('YYYY:MM:DD'); | ||
@@ -27,2 +30,5 @@ //=> '2015:04:01' | ||
timestamp('YYYY:MM'); | ||
//=> '2015:04' | ||
timestamp('YYYY'); | ||
@@ -59,11 +65,11 @@ //=> '2015' | ||
* [days](https://github.com/jonschlinkert/days): Days of the week. | ||
* [iso-week](https://github.com/jonschlinkert/iso-week): Get the ISO week of the year. | ||
* [month](https://github.com/jonschlinkert/month): Get the name or number of the current month or any month of the year. | ||
* [months](https://github.com/jonschlinkert/months): Months of the year. | ||
* [o-clock](https://github.com/jonschlinkert/o-clock): Simple utility for displaying the time in 12-hour clock format. | ||
* [seconds](https://github.com/jonschlinkert/seconds): Get the number of seconds for a minute, hour, day and week. | ||
* [weekday](https://github.com/jonschlinkert/weekday): Get the name and number of the current weekday. Or get the name of the… [more](https://github.com/jonschlinkert/weekday) | ||
* [week](https://github.com/jonschlinkert/week): Get the current week number. | ||
* [year](https://github.com/jonschlinkert/year): Simple utility to get the current year with 2 or 4 digits. | ||
* [days](https://www.npmjs.com/package/days): Days of the week. | [homepage](https://github.com/jonschlinkert/days) | ||
* [iso-week](https://www.npmjs.com/package/iso-week): Get the ISO week of the year. | [homepage](https://github.com/jonschlinkert/iso-week) | ||
* [month](https://www.npmjs.com/package/month): Get the name or number of the current month or any month of the year. | [homepage](https://github.com/datetime/month) | ||
* [months](https://www.npmjs.com/package/months): Months of the year. | [homepage](https://github.com/jonschlinkert/months) | ||
* [o-clock](https://www.npmjs.com/package/o-clock): Simple utility for displaying the time in 12-hour clock format. | [homepage](https://github.com/jonschlinkert/o-clock) | ||
* [seconds](https://www.npmjs.com/package/seconds): Get the number of seconds for a minute, hour, day and week. | [homepage](https://github.com/jonschlinkert/seconds) | ||
* [week](https://www.npmjs.com/package/week): Get the current week number. | [homepage](https://github.com/jonschlinkert/week) | ||
* [weekday](https://www.npmjs.com/package/weekday): Get the name and number of the current weekday. Or get the name of the… [more](https://www.npmjs.com/package/weekday) | [homepage](https://github.com/jonschlinkert/weekday) | ||
* [year](https://www.npmjs.com/package/year): Simple utility to get the current year with 2 or 4 digits. | [homepage](https://github.com/jonschlinkert/year) | ||
@@ -74,4 +80,4 @@ ## Running tests | ||
```bash | ||
npm i -d && npm test | ||
```sh | ||
$ npm i -d && npm test | ||
``` | ||
@@ -81,3 +87,3 @@ | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/time-stamp/issues) | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/time-stamp/issues/new). | ||
@@ -93,3 +99,3 @@ ## Author | ||
Copyright (c) 2015 Jon Schlinkert | ||
Copyright © 2015 Jon Schlinkert | ||
Released under the MIT license. | ||
@@ -99,4 +105,2 @@ | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on May 01, 2015._ | ||
<!-- reflinks generated by verb-reflinks plugin --> | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on October 10, 2015._ |
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
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
5962
0
98
41
1
- Removedpad-left@^1.0.1
- Removedpad-left@1.0.2(transitive)
- Removedrepeat-string@1.6.1(transitive)