Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

clocker

Package Overview
Dependencies
Maintainers
3
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clocker - npm Package Compare versions

Comparing version 1.15.0 to 1.15.1

test/utils.spec.js

43

lib/index.js

@@ -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": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc