Pathologic was missing because of a .git folder inside.
[yaffs-website] / node_modules / time-stamp / index.js
1 /*!
2  * time-stamp <https://github.com/jonschlinkert/time-stamp>
3  *
4  * Copyright (c) 2015, Jon Schlinkert.
5  * Licensed under the MIT License.
6  */
7
8 'use strict';
9
10 /**
11  * Parse the given pattern and return a formatted
12  * timestamp.
13  *
14  * @param  {String} `pattern` Date pattern.
15  * @param  {Date} `date` Date object.
16  * @return {String}
17  */
18
19 module.exports = function timestamp(pattern, date) {
20   if (typeof pattern !== 'string') {
21     date = pattern;
22     pattern = 'YYYY:MM:DD';
23   }
24   date = date || new Date();
25   return pattern.replace(/([YMDHms]{2,4})(:\/)?/g, function(_, key, sep) {
26     var increment = method(key);
27     if (!increment) return _;
28     sep = sep || '';
29
30     var res = '00' + String(date[increment[0]]() + (increment[2] || 0));
31     return res.slice(-increment[1]) + sep;
32   });
33 };
34
35 function method(key) {
36   return ({
37    YYYY: ['getFullYear', 4],
38    YY: ['getFullYear', 2],
39    // getMonth is zero-based, thus the extra increment field
40    MM: ['getMonth', 2, 1],
41    DD: ['getDate', 2],
42    HH: ['getHours', 2],
43    mm: ['getMinutes', 2],
44    ss: ['getSeconds', 2],
45    ms: ['getMilliseconds', 3]
46   })[key];
47 }