-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- move regex outside of function - use replacer function instead of recursive function calls
- Loading branch information
1 parent
7ab558b
commit ec0ce08
Showing
5 changed files
with
207 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,96 +1,115 @@ | ||
## v2.0.0 | ||
|
||
**Breaking changes** | ||
|
||
Default pattern was changed from `YYYY:MM:DD` to `YYYY-MM-DD`. See https://github.com/jonschlinkert/time-stamp/issues/3 for more details. | ||
|
||
## Usage | ||
|
||
```js | ||
var timestamp = require('{%= name %}'); | ||
const timestamp = require('{%= name %}'); | ||
|
||
timestamp(); | ||
console.log(timestamp()); | ||
//=> {%= timestamp() %} | ||
timestamp.utc(); | ||
|
||
console.log(timestamp.utc()); | ||
//=> {%= timestampUTC() %} | ||
``` | ||
|
||
## Customizing the timestamp | ||
|
||
timestamp('YYYYMMDD'); | ||
You may also pass a string to format the generated timestamp. | ||
|
||
```js | ||
console.log(timestamp('YYYYMMDD')); | ||
//=> {%= timestamp('YYYYMMDD') %} | ||
timestamp.utc('YYYYMMDD'); | ||
|
||
console.log(timestamp.utc('YYYYMMDD')); | ||
//=> {%= timestampUTC('YYYYMMDD') %} | ||
``` | ||
|
||
**Supported patterns** | ||
|
||
timestamp('YYYYMMDD:ss'); | ||
- `YYYY`: full year (ex: **{%= timestamp("YYYY") %}**) | ||
- `MM`: month (ex: **04**) | ||
- `DD`: day (ex: **01**) | ||
- `HH`: hours (ex: **12**) | ||
- `mm`: minutes (ex: **59**) | ||
- `ss`: seconds (ex: **09**) | ||
- `ms`: milliseconds (ex: **532**) | ||
|
||
**Usage Examples** | ||
|
||
```js | ||
console.log(timestamp('YYYYMMDD')); | ||
//=> {%= timestamp('YYYYMMDD') %} | ||
console.log(timestamp.utc('YYYYMMDD')); | ||
//=> {%= timestampUTC('YYYYMMDD') %} | ||
|
||
console.log(timestamp('YYYYMMDD:ss')); | ||
//=> {%= timestamp('YYYYMMDD:ss') %} | ||
timestamp.utc('YYYYMMDD:ss'); | ||
console.log(timestamp.utc('YYYYMMDD:ss')); | ||
//=> {%= timestampUTC('YYYYMMDD:ss') %} | ||
|
||
timestamp('YYYY/MM/DD:mm:ss'); | ||
console.log(timestamp('YYYY/MM/DD:mm:ss')); | ||
//=> {%= timestamp('YYYY/MM/DD:mm:ss') %} | ||
timestamp.utc('YYYY/MM/DD:mm:ss'); | ||
console.log(timestamp.utc('YYYY/MM/DD:mm:ss')); | ||
//=> {%= timestampUTC('YYYY/MM/DD:mm:ss') %} | ||
|
||
timestamp('YYYY:MM:DD'); | ||
console.log(timestamp('YYYY:MM:DD')); | ||
//=> {%= timestamp('YYYY:MM:DD') %} | ||
timestamp.utc('YYYY:MM:DD'); | ||
console.log(timestamp.utc('YYYY:MM:DD')); | ||
//=> {%= timestampUTC('YYYY:MM:DD') %} | ||
|
||
timestamp('[YYYY:MM:DD]'); | ||
console.log(timestamp('[YYYY:MM:DD]')); | ||
//=> {%= timestamp('[YYYY:MM:DD]') %} | ||
timestamp.utc('[YYYY:MM:DD]'); | ||
console.log(timestamp.utc('[YYYY:MM:DD]')); | ||
//=> {%= timestampUTC('[YYYY:MM:DD]') %} | ||
|
||
timestamp('YYYY/MM/DD'); | ||
console.log(timestamp('YYYY/MM/DD')); | ||
//=> {%= timestamp('YYYY/MM/DD') %} | ||
timestamp.utc('YYYY/MM/DD'); | ||
console.log(timestamp.utc('YYYY/MM/DD')); | ||
//=> {%= timestampUTC('YYYY/MM/DD') %} | ||
|
||
timestamp('YYYY:MM'); | ||
console.log(timestamp('YYYY:MM')); | ||
//=> {%= timestamp('YYYY:MM') %} | ||
timestamp.utc('YYYY:MM'); | ||
console.log(timestamp.utc('YYYY:MM')); | ||
//=> {%= timestampUTC('YYYY:MM') %} | ||
|
||
timestamp('YYYY'); | ||
console.log(timestamp('YYYY')); | ||
//=> {%= timestamp('YYYY') %} | ||
timestamp.utc('YYYY'); | ||
console.log(timestamp.utc('YYYY')); | ||
//=> {%= timestampUTC('YYYY') %} | ||
|
||
timestamp('MM'); | ||
console.log(timestamp('MM')); | ||
//=> {%= timestamp('MM') %} | ||
timestamp.utc('MM'); | ||
console.log(timestamp.utc('MM')); | ||
//=> {%= timestampUTC('MM') %} | ||
|
||
timestamp('DD'); | ||
console.log(timestamp('DD')); | ||
//=> {%= timestamp('DD') %} | ||
timestamp.utc('DD'); | ||
console.log(timestamp.utc('DD')); | ||
//=> {%= timestampUTC('DD') %} | ||
|
||
timestamp('HH'); | ||
console.log(timestamp('HH')); | ||
//=> {%= timestamp('HH') %} | ||
timestamp.utc('HH'); | ||
console.log(timestamp.utc('HH')); | ||
//=> {%= timestampUTC('HH') %} | ||
|
||
timestamp('mm'); | ||
console.log(timestamp('mm')); | ||
//=> {%= timestamp('mm') %} | ||
timestamp.utc('mm'); | ||
console.log(timestamp.utc('mm')); | ||
//=> {%= timestampUTC('mm') %} | ||
|
||
timestamp('ss'); | ||
console.log(timestamp('ss')); | ||
//=> {%= timestamp('ss') %} | ||
timestamp.utc('ss'); | ||
console.log(timestamp.utc('ss')); | ||
//=> {%= timestampUTC('ss') %} | ||
|
||
timestamp('ms'); | ||
console.log(timestamp('ms')); | ||
//=> {%= timestamp('ms') %} | ||
timestamp.utc('ms'); | ||
console.log(timestamp.utc('ms')); | ||
//=> {%= timestampUTC('ms') %} | ||
``` | ||
|
||
**Valid patterns** | ||
## Release history | ||
|
||
- `YYYY`: full year (ex: **{%= timestamp("YYYY") %}**) | ||
- `MM`: month (ex: **04**) | ||
- `DD`: day (ex: **01**) | ||
- `HH`: hours (ex: **12**) | ||
- `mm`: minutes (ex: **59**) | ||
- `ss`: seconds (ex: **09**) | ||
- `ms`: milliseconds (ex: **532**) | ||
### v2.0.0 | ||
|
||
**Breaking changes** | ||
|
||
Default pattern was changed from `YYYY:MM:DD` to `YYYY-MM-DD`. See [issues/3](../../issues) for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.