Skip to content

Instantly share code, notes, and snippets.

@julik
Last active June 11, 2025 13:02
Show Gist options
  • Save julik/d6c4a3a32a3145d5e7467baa4e1868e2 to your computer and use it in GitHub Desktop.
Save julik/d6c4a3a32a3145d5e7467baa4e1868e2 to your computer and use it in GitHub Desktop.

Revisions

  1. julik revised this gist Jun 11, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion timetracker.js
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ var fromDate = new Date(2025, 4, 25)
    var evts = theCalendar.events.whose(
    {_and: [
    {summary: { _beginsWith: eventNamePrefix }},
    {startDate: { _greaterThan: fromDate}}
    {startDate: { _greaterThan: fromDate}}
    ]
    }
    );
  2. julik revised this gist Jun 11, 2025. 1 changed file with 6 additions and 5 deletions.
    11 changes: 6 additions & 5 deletions timetracker.js
    Original file line number Diff line number Diff line change
    @@ -6,11 +6,12 @@ const eventNamePrefix = "Amazing Project 123";
    var theCalendar = Calendar.calendars.whose({name: calendarName})[0]
    var fromDate = new Date(2025, 4, 25)
    var evts = theCalendar.events.whose(
    {_and: [
    {summary: { _beginsWith: eventNamePrefix }},
    {startDate: { _greaterThan: fromDate}}
    ]}
    );
    {_and: [
    {summary: { _beginsWith: eventNamePrefix }},
    {startDate: { _greaterThan: fromDate}}
    ]
    }
    );
    // Resolve the array
    let totalHours = 0;
    for (var evtHandleFn of evts()) {
  3. julik renamed this gist Jun 10, 2025. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. julik created this gist Jun 10, 2025.
    28 changes: 28 additions & 0 deletions timetracker.jx
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    var Calendar = Application("Calendar")

    const calendarName = "My Calendar";
    const eventNamePrefix = "Amazing Project 123";

    var theCalendar = Calendar.calendars.whose({name: calendarName})[0]
    var fromDate = new Date(2025, 4, 25)
    var evts = theCalendar.events.whose(
    {_and: [
    {summary: { _beginsWith: eventNamePrefix }},
    {startDate: { _greaterThan: fromDate}}
    ]}
    );
    // Resolve the array
    let totalHours = 0;
    for (var evtHandleFn of evts()) {
    let evtHandle = evtHandleFn();
    let summary = evtHandle.summary();
    let sd = evtHandle.startDate();
    let ed = evtHandle.endDate();
    let durationMillis = ed - sd;
    let durationHours = durationMillis / 1000 / 60 / 60;
    totalHours += durationHours;
    const [formattedDate] = sd.toISOString().split('T');

    console.log(`${formattedDate}: ${summary} took ${durationHours.toFixed(2)} hours`);
    }
    console.log(`${totalHours.toFixed(2)} total hours`);