Skip to content

Commit

Permalink
chore: validate timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
shivam-sharma7 committed Oct 25, 2024
1 parent f7a7eaa commit 1bab31d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ This is a lightweight and timezone-aware date utility package built on top of th
- Get the current time in any timezone. (e.g., Asia/Kolkata)
- Calculate the time difference (in hours) between two timezones.
- Supports for both JavaScript and TypeScript developer.
- Mental Health Time Manager, allowing users to set their work preferences.

There are many more features available in the package.
There are many more features available in the package. [Jump to docs](#documentation).

## Download/install

Expand Down
1 change: 1 addition & 0 deletions docs/home.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ This is a lightweight and timezone-aware date utility package built on top of th
- Get the current time in any timezone. (e.g., Asia/Kolkata)
- Calculate the time difference (in hours) between two timezones.
- Supports for both JavaScript and TypeScript developer.
- Mental Health Time Manager, allowing users to set their work preferences.

## Why world-clockify?

Expand Down
5 changes: 5 additions & 0 deletions src/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,11 @@ export const sheduleWorkAndBreaks = (preference: UserPreferences) => {

const workSession = [];
const breakTime = [];
if (!IANAZone.isValidZone(preferredTimeZone)) {
throw Error(
`Invalid timezone: "${preferredTimeZone}". Please provide a valid IANA timezone (e.g., 'America/New_York').`,
);
}

let currentTime = DateTime.fromFormat(workStartTime, 'HH:mm', { zone: preferredTimeZone });
const endOfWorkDay = DateTime.fromFormat(workEndTime, 'HH:mm', { zone: preferredTimeZone });
Expand Down

0 comments on commit 1bab31d

Please sign in to comment.