Skip to content

alrico88/date-formatter

Repository files navigation

Classes

DatesFormatter

Typedefs

FormatterOptions

DatesFormatter

Kind: global class

new DatesFormatter()

DatesFormatter Class

datesFormatter.format(date, [asUTC]) ⇒ string

Formats Date object as string

Kind: instance method of DatesFormatter
Returns: string - String representation of Date

Param Type Default Description
date Date Date object to convert
[asUTC] boolean true Whether to use date input as UTC

datesFormatter.formatRange(dateRange, [asUTC]) ⇒ Array.<string>

Formats date range as strings

Kind: instance method of DatesFormatter
Returns: Array.<string> - String representation of Dates

Param Type Default Description
dateRange Array.<Date> Date range to convert
[asUTC] boolean true Whether to use date input as UTC

datesFormatter.parse(dateString, [asUTC]) ⇒ Date

Parses date string to Date

Kind: instance method of DatesFormatter
Returns: Date - The parsed date

Param Type Default Description
dateString string Date string to parse
[asUTC] boolean true Whether to use date input as UTC

datesFormatter.parseRange(dateStringRange, [asUTC]) ⇒ Array.<Date> | Array.<object>

Parses date string arrays to Date

Kind: instance method of DatesFormatter
Returns: Array.<Date> | Array.<object> - The parsed dates

Param Type Default Description
dateStringRange Array.<string> Date strings array to parse
[asUTC] boolean true Whether to use date input as UTC

DatesFormatter.DatesFormatter

Kind: static class of DatesFormatter

new DatesFormatter(mode, [options])

Creates an instance of DatesFormatter.

Param Type Default Description
mode 'year' | 'month' | 'week' | 'date' Mode to use for formatting
[options] FormatterOptions {} Config to override default formatter strings

modes

Kind: global enum
Properties

Name Default
YEAR year
MONTH month
WEEK week
DATE date

FormatterOptions

Kind: global typedef
Properties

Name Type
[dateFormat] string
[weekFormat] string
[monthFormat] string
[yearFormat] string

About

Helper to format and parse dates in different ways

Resources

License

Stars

Watchers

Forks

Packages

No packages published