Skip to content

Feature: NepalTimezoneDate class  #104

@aj3sh

Description

@aj3sh

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions