Skip to content

Commit

Permalink
fix end of day work hours parsing (#482)
Browse files Browse the repository at this point in the history
* fix end of day work hours parsing

* remove quotes
  • Loading branch information
xavluiz authored Mar 4, 2024
1 parent 2c8293e commit 82e837e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "swdc-vscode",
"displayName": "Code Time",
"version": "2.7.5",
"version": "2.7.6",
"publisher": "softwaredotcom",
"description": "Code Time is an open source plugin that provides programming metrics right in Visual Studio Code.",
"author": {
Expand Down Expand Up @@ -151,4 +151,4 @@
"uuid": "^9.0.1",
"ws": "^8.14.2"
}
}
}
14 changes: 12 additions & 2 deletions src/notifications/endOfDay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ import { getCachedUser, isRegistered } from '../DataController';

const MIN_IN_MILLIS = 60 * 1000;
const HOUR_IN_MILLIS = 60 * 60 * 1000;
const DEFAULT_WORK_HOURS = {
mon: { ranges: [ { start: "09:00", end: "17:00" } ], active: true },
tue: { ranges: [ { start: "09:00", end: "17:00" } ], active: true },
wed: { ranges: [ { start: "09:00", end: "17:00" } ], active: true },
thu: { ranges: [ { start: "09:00", end: "17:00" } ], active: true },
fri: { ranges: [ { start: "09:00", end: "17:00" } ], active: true },
sat: { ranges: [ { start: "09:00", end: "17:00" } ], active: false },
sun: { ranges: [ { start: "09:00", end: "17:00" } ], active: false }
}

let timer: NodeJS.Timeout | undefined = undefined;

Expand All @@ -19,7 +28,8 @@ export const setEndOfDayNotification = async () => {

const cachedUser: any = await getCachedUser();
const preferences: any = cachedUser.preferences_parsed;
const workHours: any = JSON.parse(cachedUser.profile.work_hours)

const workHours: any = cachedUser.profile?.work_hours ? JSON.parse(cachedUser.profile.work_hours) : DEFAULT_WORK_HOURS

// If the end of day notification setting is turned on (if undefined or null, will default to true)
if (preferences.notifications?.endOfDayNotification) {
Expand All @@ -38,7 +48,7 @@ export const setEndOfDayNotification = async () => {
if (work_hours_today?.active) {
// it's active, get the largest end range
const endTimes = work_hours_today.ranges.map((n: any) => {
// convert "end" to total seconds in a day
// convert end to total seconds in a day
return getEndTimeSeconds(n.end);
});

Expand Down
Binary file renamed swdc-vscode-2.7.5.vsix → swdc-vscode-2.7.6.vsix
Binary file not shown.

0 comments on commit 82e837e

Please sign in to comment.