
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
ChronoBox is a lightweight, versatile, and easy-to-use TypeScript library for handling date manipulation and formatting. It provides a powerful API for adding, subtracting, comparing, and formatting dates.
npm install chronobox
The ChronoBox class provides a convenient and powerful API for date manipulation, formatting, and validation.
new ChronoBox<TFormat extends DateFormat | CustomFormat = DateFormat>(date?: DateInput, format?: TFormat)
add<T extends TimeUnit>(amount: number, unit: T): ChronoBox<TFormat>
Adds a specified amount of time to the current date.
subtract<T extends TimeUnit>(amount: number, unit: T): ChronoBox<TFormat>
Subtracts a specified amount of time from the current date.
diff(other: DateInput, unit: TimeUnit = TimeUnit.DAYS): number
Calculates the difference between the current date and another date in the specified time unit.
getComponents(): DateComponents
Returns the individual components (year, month, day, hours, minutes, seconds, milliseconds) of the date.
formatDate(): string
Formats the current date according to the specified format.
isValid(): boolean
Checks whether the current date is valid.
toDate(): Date
Returns the underlying Date object from the ChronoBox instance.
withFormat<NewFormat extends DateFormat | CustomFormat>(newFormat: NewFormat): ChronoBox<NewFormat>
Creates a new ChronoBox instance with a different format.
isAfter(other: DateInput, granularity: TimeUnit = TimeUnit.MILLISECONDS): boolean
Checks if this date is after the specified date.
isBefore(other: DateInput, granularity: TimeUnit = TimeUnit.MILLISECONDS): boolean
Checks if this date is before the specified date.
convertTimezone(date: Date | ChronoBox, fromTimezone: string, toTimezone: string): Date
Converts a date from one timezone to another
getTimezoneOffsetMinutes(date: Date | ChronoBox, timezone: string): number
Gets the timezone offset in minutes for a date in a specific timezone.
isInDST(date: Date | ChronoBox, timezone: string): boolean
Checks if a date is in Daylight Saving Time (DST) for a specific timezone.
findDSTTransitions(year: number, timezone: string): { start: Date | null; end: Date | null }
Finds the exact DST transition times for a given year in a specific timezone.
startOf<T extends TimeUnit>(unit: T): ChronoBox<TFormat>
Gets the start of a specified time unit for the current date.
endOf<T extends TimeUnit>(unit: T): ChronoBox<TFormat>
Gets the end of a specified time unit for the current date.
fromNow(referenceDate?: DateInput): string
Gets a human-readable string representing the time difference between the current date and now.
ChronoBox is open-source software, licensed under the MIT License.
If you find ChronoBox helpful, please give it a ⭐️ on GitHub and share it with your fellow developers!
FAQs
A TypeScript date manipulation library
We found that chronobox demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.