Created
May 16, 2016 20:28
-
-
Save S2Ler/fa840376d706401db759323633c1282d to your computer and use it in GitHub Desktop.
BillingTimer build worksheet from timers
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
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