Skip to content

chore: made sure timezone is an optional argument#14

Merged
shubham-thanki-at-sandbox merged 4 commits into
mainfrom
feature/date-util-time-zone
Apr 15, 2026
Merged

chore: made sure timezone is an optional argument#14
shubham-thanki-at-sandbox merged 4 commits into
mainfrom
feature/date-util-time-zone

Conversation

@shubham-thanki-at-sandbox

Copy link
Copy Markdown
Contributor

This pull request refactors and improves the DateUtil class in src/utils/date/DateUtil.ts, focusing on standardizing timezone handling, simplifying internal logic, and making the API more consistent and user-friendly. Most methods now default to using UTC if no timezone is specified, and several helper methods have been introduced to reduce code duplication. The version in package.json is also incremented.

Key improvements include:

Timezone Handling & Consistency:

  • Introduced a new DEFAULT_TIMEZONE constant (set to 'UTC') and the resolveTimeZone/toTZDate helper methods, ensuring all date operations consistently use UTC by default unless a timezone is provided. This change also updates method signatures and documentation to reflect the new default behavior. [1] [2] [3]

API Simplification & Refactoring:

  • Refactored methods like printDate, getStartOfDay, getEndOfDay, daysInBetween, monthsInBetween, yearsInBetween, and addDuration to use the new helpers, reducing code duplication and improving readability. [1] [2] [3] [4] [5]
  • Removed the old normalizeDate helper in favor of the new approach.

API Improvements:

  • Updated method signatures to make the timeZone parameter optional (defaulting to UTC) and improved JSDoc comments for clarity. [1] [2] [3]

Minor Fixes:

  • Updated the isLeapYear method to use the new timezone handling.
  • Cleaned up imports and formatting for better readability.

Version Bump:

  • Incremented the package version to 2.0.7 in package.json.

@shubham-thanki-at-sandbox shubham-thanki-at-sandbox changed the title chore: made sure timezone is optional argument chore: made sure timezone is an optional argument Apr 14, 2026
@shubham-thanki-at-sandbox shubham-thanki-at-sandbox merged commit 90b9763 into main Apr 15, 2026
1 check passed
@shubham-thanki-at-sandbox shubham-thanki-at-sandbox deleted the feature/date-util-time-zone branch April 15, 2026 05:48
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

Successfully merging this pull request may close these issues.

3 participants