Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: NepalTimezoneDate class #104

Open
aj3sh opened this issue Dec 28, 2024 · 0 comments
Open

Feature: NepalTimezoneDate class #104

aj3sh opened this issue Dec 28, 2024 · 0 comments

Comments

@aj3sh
Copy link
Member

aj3sh commented Dec 28, 2024

Use Case
Prerequisite: The system must be running in a different timezone (e.g., UTC).

When the system is in a different timezone, handling dates and times specific to Nepal's timezone (Asia/Kathmandu) can be challenging. For instance, if we have a date/time string in Nepal's timezone, there is no direct way to retrieve Nepal-specific values like the year, month, day, hour, or minutes. Instead, it always returns data in the system's timezone data.

Thanks to the NepaliDate class, from which this can be achieved. However, introducing this feature could also benefit the NepaliDate class by improving logic decoupling. Additionally, not every use case requires converting the date to the Nepali calendar.

Proposed Solution
Create a NepalTimezoneDate class that extends JavaScript's Date object. The NepalTimezoneDate object would behave exactly like a Date object operating on Asia/Kathmandu timezone.

Example Usage:

const date1 = new Date();
// 2024-12-28T15:00:35.170Z

const date2 = new NepalTimezoneDate();
// 2024-12-28 20:45:35 GMT+0545

date2.getYear(); // 2024
date2.getMinutes(); // 45

Alternatives Considered
N/A

Dependencies
N/A

Additional Context
The logic implemented in NepaliDate are in src/utils.ts > getNepalDateAndTime and getDate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant