Skip to content

Instantly share code, notes, and snippets.

@S2Ler
Created May 16, 2016 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save S2Ler/fa840376d706401db759323633c1282d to your computer and use it in GitHub Desktop.
Save S2Ler/fa840376d706401db759323633c1282d to your computer and use it in GitHub Desktop.
BillingTimer build worksheet from timers
function buildWorkLog(timers) {
var worklog = ''
for (t in timers) {
worklog += timers[t].pause_date() + ': ' + timers[t].name() + ' ' + timers[t].formatted_time() + '\n'
}
return worklog
}
function saveWorkLog(worklog) {
finder = Application("Finder")
finder.includeStandardAdditions = true
const pathToSave = finder.chooseFileName({defaultName: 'worklog.txt'})
ObjC.import('Cocoa');
str = $.NSString.alloc.initWithUTF8String(worklog);
str.writeToFileAtomically(pathToSave.toString(), true);
}
function deleteTimers(timers) {
const ids = timers.id()
for (i in ids) {
id = ids[i]
timers.byId(id).delete_timer()
}
}
const app = Application("BillingTimer")
const timers = app.timers
saveWorkLog(buildWorkLog(timers))
deleteTimers(timers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment