Comparing version 1.15.0 to 1.15.1
@@ -0,1 +1,5 @@ | ||
const toStamp = require('./util').toStamp | ||
const {formatElapsed, getKey} = require('./util') | ||
module.exports = Clocker | ||
@@ -27,4 +31,2 @@ | ||
Clocker.KEY_FORMAT = 'time!%F %T' | ||
Clocker.RESERVED_DATA_ENTRIES = [ | ||
@@ -54,9 +56,3 @@ 'start', | ||
Clocker.formatElapsed = function (elapsed) { | ||
var n = elapsed | ||
var hh = pad(Math.floor(n / 60 / 60), 2) | ||
var mm = pad(Math.floor(n / 60 % 60), 2) | ||
var ss = pad(Math.floor(n % 60), 2) | ||
return [ hh, mm, ss ].join(':') | ||
} | ||
Clocker.formatElapsed = formatElapsed | ||
@@ -93,3 +89,3 @@ Clocker.prototype.close = function (cb) { | ||
var type = data.type | ||
var pkey = strftime(Clocker.KEY_FORMAT, date) | ||
var pkey = getKey(date) | ||
var tkey = 'time-type!' + type + '!' + strftime('%F %T', date) | ||
@@ -182,3 +178,3 @@ try { | ||
var seconds = elapsed / 1000 | ||
return cb(null, 'elapsed time: ' + Clocker.formatElapsed(seconds)) | ||
return cb(null, 'elapsed time: ' + formatElapsed(seconds)) | ||
} | ||
@@ -288,3 +284,3 @@ | ||
var newId = strftime(Clocker.KEY_FORMAT, update[startKey]) | ||
var newId = getKey(update[startKey]) | ||
if (newId !== id) { | ||
@@ -489,24 +485,1 @@ this.db.batch([ | ||
} | ||
function pad (s, len) { | ||
return Array(Math.max(0, len - String(s).length + 1)).join('0') + s | ||
} | ||
function getKey (x) { | ||
if (x === 'NaN') { | ||
return strftime(Clocker.KEY_FORMAT, new Date(NaN)) | ||
} | ||
if (typeof x === 'object' && x instanceof Date) { | ||
return strftime(Clocker.KEY_FORMAT, x) | ||
} | ||
if (!/^\d+$/.test(x)) { | ||
return 'time!' + x | ||
} | ||
return strftime(Clocker.KEY_FORMAT, new Date(x * 1000)) | ||
} | ||
function toStamp (s) { | ||
return Math.floor(new Date(s.split('!')[1]).valueOf() / 1000) | ||
} |
@@ -1,7 +0,6 @@ | ||
module.exports = {} | ||
module.exports.getDate = getDate | ||
module.exports.isUnixTimestamp = isUnixTimestamp | ||
var parseTime = require('parse-messy-time') | ||
var strftime = require('strftime') | ||
const KEY_FORMAT = 'time!%F %T' | ||
function getDate (expr) { | ||
@@ -29,1 +28,43 @@ var d | ||
} | ||
function formatElapsed (elapsed) { | ||
var n = elapsed | ||
var hh = pad(Math.floor(n / 60 / 60), 2) | ||
var mm = pad(Math.floor(n / 60 % 60), 2) | ||
var ss = pad(Math.floor(n % 60), 2) | ||
return [ hh, mm, ss ].join(':') | ||
} | ||
function pad (s, len) { | ||
return Array(Math.max(0, len - String(s).length + 1)).join('0') + s | ||
} | ||
function toStamp (stringWithTimestamp) { | ||
return Math.floor(new Date(stringWithTimestamp.split('!')[1]).valueOf() / 1000) | ||
} | ||
function getKey (x) { | ||
if (x === 'NaN') { | ||
return getKeyFromDate(new Date(NaN)) | ||
} | ||
if (typeof x === 'object' && x instanceof Date) { | ||
return getKeyFromDate(x) | ||
} | ||
if (!/^\d+$/.test(x)) { | ||
return 'time!' + x | ||
} | ||
return getKeyFromDate(new Date(x * 1000)) | ||
} | ||
function getKeyFromDate (date) { | ||
return strftime(KEY_FORMAT, date) | ||
} | ||
module.exports = { | ||
getDate, | ||
formatElapsed, | ||
toStamp, | ||
getKey | ||
} |
{ | ||
"name": "clocker", | ||
"version": "1.15.0", | ||
"version": "1.15.1", | ||
"description": "track project hours", | ||
@@ -5,0 +5,0 @@ "bin": { |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
113877
10
1920
0