@phensley/cldr-types
Types shared among packages in the @phensley/cldr
library
Types shared among packages in the @phensley/cldr library
Types shared among packages in the @phensley/cldr
library
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project This project uses a modified semantic versioning scheme. See README for more details.
inlineSources: true
to add Typescript source code to source maps.inlineSources: true
to add Typescript source code to source maps.cldr-compiler pack
command now includes the ability to apply patches to the resource packs, allowing you to replace CLDR values with your own. See the included example.cldr-compiler schema
will dump the CLDR data schema used to generate resource packs. This is helpful in identifying the full path to a value you may want to patch.CalendarDate
for ISO weeks.The phensley/timezone
package includes a new TZ.zoneMeta
method to return metadata for a timezone. This can be useful for displaying user interfaces for choosing a timezone. The new properties are:
stdoffset
- Current standard offset, in milliseconds.latitude
- Latitude to 6 decimal places, for the timezone's "principal location"longitude
- Latitude to 6 decimal places, for the timezone's "principal location"countries
- List of ISO 3166 2-letter country codes for countries which overlap the timezone.The cldr.Calendars.timeZoneInfo
result TimeZoneInfo
now includes the same properties as TZ.zoneMeta
above, plus the following property:
metazone
Current CLDR metazone for the timezone.tslib ^1.13.0
@phensley/*
package interdependencies now use the ^x.x.x
constraint.@phensley/cldr-schema
, merging its code into @phensley/cldr-core
.major.minor
version of the @phensley/cldr-core
package at runtime to ensure schema compatibility.CLDR.Numbers.parseDecimal
convenience method to parse a number or string into a Decimal
instance.CLDR.Calendars.timeZoneFromUTC
and CLDR.Calendars.timeZoneFromWall
convenience methods to lookup time zone info from either a UTC or local "wall clock" timestamp.trimZeroFractions
option to format an amount as a whole number when the fractional digits are all zero. With this option 10.00
formats as "$10"
, but 10.10
would still format as "$10.10"
. This option has no effect if the minimumFractionDigits
option is also set.Calendars.newGregorianDate(fields)
for each calendar type.Calendars.now()
and Calendars.nowGregorian()
for each calendar type.CalendarDate.asJSDate()
converts a CalendarDate
to a JavaScript Date
.CalendarDate.set(fields)
to set one or more fields on a date.CalendarDate.fields()
returns a TimePeriod
populated with a date's field values.CalendarDate.toISOString()
returns an Gregorian ISO-8601 string of the UTC timestamp.CalendarDate.toLocalISOString()
returns an Gregorian ISO-8601 string of the local timestamp.Calendars.formatDateWrapper()
method to wrap a date and time that have been formatted separately. Can be used to join a relative date format with a time, e.g. "Next Wednesday at 3:30 PM".CalendarDate.differenceSigned()
method to return signed values (.difference()
returns absolute value).alt
property:era
default for Gregorian is "Before Christ" and "Anno Domini".
Specifying the { alt: { era: 'sensitive' }}
option will use "Before Common Era" and "Common Era".dayPeriod
default for Gregorian in US English is "AM" and "PM".
Specifying the { alt: { dayPeriod: 'casing' }}
option will use lowercase forms "am" and "pm".Calendars.firstDayOfWeek()
and Calendars.minDaysInFirstWeek()
methods.The following values of UnitType
have been renamed in the underlying CLDR data.
| old | new |
| -------------------------- | ----------------------------- |
| meter-per-second-squared
| meter-per-square-second
|
| part-per-million
| permillion
|
| liter-per-100kilometers
| liter-per-100-kilometer
|
| millimeter-of-mercury
| millimeter-ofhg
|
| pound-per-square-inch
| pound-force-per-square-inch
|
| inch-hg
| inch-ofhg
|
| pound-foot
| pound-force-foot
|
TimePeriod
fields are no longer optional, and CalendarDate.add
and .subtract
now take a Partial<TimePeriod>
to allow fields to be omitted.CalendarDate.toString
now formats the era-less extended year for consistency.@phensley/cldr-types
package.latn
number systems for compact number formats.LanguageTag
and Locale
instances.leftPad
internal function.LanguageResolver
to substitute aliases in a language tagLocaleMatcher
can be passed an array of language tag and locale instances, bypassing parsing.LocaleMatcher
constructor now accepts an options parameter.resolve: boolean
can be used to disable locale resolution if the tags have already been fully resolved.Date
arguments to calendar methods.temperature
.short
, medium
, etc) with skeletons. For example formatDate(date, { date: 'short', skeleton: 'hm' })
SchemaConfig
from the CLDRFramework
.Decimal
.String.codePointAt
that affected IE11 w/out polyfillscldr-compiler
package.@phensley/unit-converter
package allowing customized conversion between units. Comes with default conversion factors for most CLDR units.@phensley/plurals
Decimal
division and fixed edge cases with scale
math contexttimes
unit that slipped in due to a bug in filtering out unit patternsdate
and time
skeleton options for date interval formatting. These are used when the start and end dates differ by more or less than 1 day.string
or LanguageTag
argumentSplit locale-related code into 3 new packages which can be used independently of the main library:
@phensley/language-tag
implements BCP 47 language tag parsing and construction.@phensley/locale
implements resolving of language tags by alias and likely subtags substitution.@phensley/locale-matcher
implements distance based locale matching using the CLDR enhanced language matching algorithm.@phensley/plurals
and @phensley/messageformat
APIs"pt-PT"
@phensley/decimal
MessageFormatter
and MessageFormatterOptions
from top-level packagesMessageFormatter
class which caches parsed messages internally.General.messageFormatter(options)
method to create a message formatter for the current locale.Decimal
, number
, or string
(containing a valid number).Decimal
argument instead of number operands.decimal
package into plurals
.@phensley/cldr-types
MessageMatcher
type@phensley/cldr-ext-rbnf
. This will enable formatting using the global algorithmic numbering systems as well as named rules. This is implemented as an extension to the main library but is not currently integrated.@phensley/cldr-types
package. This will eventually enable the core library and extension packages to be able to interface.default
properties inside resource packs. This avoids confusion with the default
property that is added by some module loaders, since resource packs can be loaded via require()
, etc.TEXT
node."_"
UNDERSCORE character to separate fields, resulting in a ~10-20% reduction in each resource pack's size.@phensley/messageformatter
public types from @phensley/cldr-core
as well.@phensley/messageformatter
public types from @phensley/cldr
so they're included in the UMD bundle.@phensley/messageformatter
package.@phensley/plurals
package so it can be used standalone.cldr-compiler dump
which dumps a resource pack, showing the internal structure.unitPattern
under the 'other'
plural category. Now we explicitly fallback to 'other'
.ja
locale now correctly encodes the date formats; they were blank in previous releases. We currently use latin digits for this locale but once RBNF is supported the year field will be formatted using the jpanyear
rule.numericOnly: boolean
and alwaysNow: boolean
to relative time formatters.times
unit to Quantity
typeRelativeTimeFieldFormatOptions
TimePeriod
type to represent time between two dates in terms of years, months, etc.Calendars.formatRelativeTime
method which formats the relative time between two datesdifference
Calendars.timePeriodToQuantity
method to convert a time period into a Quantity
sequence suitable for unit formattingCalendarDate.difference
method to compute the difference between two dates, returning a TimePeriod
TimePeriod
will be "rolled up" into only those fields, e.g. ['year', 'day']
, ['day', 'hour', 'minute']
, etcCalendarDate.compare
method to compares two dates, returning an integer indicating the date is less than (-1
), equal to (0
), or greater than (1
) the argumentCalendarDate.relativeTime
method to compute the relative time between two dates in terms of a single field, e.g. N years
CalendarDate.subtract
method equivalent to add(-timeperiod)
CalendarDate.withZone
method to return a copy using a different time zoneCalendarDateFields
with TimePeriod
fieldOfGreatestDifference
to fieldOfVisualDifference
to more accurately reflect its purpose, since it is primarily used to determine the pivot field for date interval formattingformatRelativeTimeField
options type is now RelativeTimeFieldFormatOptions
to distinguish it from the options type for formatRelativeTime
methodtslib
1.10.xlerna.json
to pull version string into libraryformatRelativeTimeField
LocaleMatcher
CLDRFramework.get/getAsync
Numbers.adjustDecimal(num, options): Decimal
method to adjust a decimal number using options, e.g. min/max fractions, etc.getCurrencyDisplayName
and getCurrencyPluralName
methods to take a number argument, which will be used to compute the plural category, and a options object to determine the display context.getPluralCardinal
and getPluralOrdinal
methods now accept decimal adjustment options, to adjust the number before the plural calculation happens. Omitting the options will interpret the number as-is.PersianDate
DisplayNameOptions
to methods for language, script, and region names.Etc/GMT+-[digit]
time zones mapped to the GMT
metazone.@phensley/cldr
default schema configuration is initialized.@phensley/cldr
library.NaN
and signed Infinity
values to Decimal
type. Operations involving these values follow IEEE 754-2008. For example, division by zero will now return signed infinity.compare()
with zero. Current representation of sign and ZERO
has too many edge cases, will be corrected in a future release.en-GB
and en-US
.Calendars.resolveTimeZoneId
which maps a timezone id or alias to the current TZDB identifier for that zone.NumberMiscPatternType
values at-least
, at-most
, approx
and range
. These are not yet used for formatting.Calendars.timeZoneIds
method now returns an array of valid TZDB identifiers instead of CLDR stable timezone identifiers.Calendars.timeZoneInfo
method now accepts a timezone identifier or alias and returns a record containing the resolved TZDB identifier and exemplar city name.UnitFormatStyleType
to omit the percent
and permille
styles from the unit formatter.cash: boolean
to enable cash rounding.divisor
option, used to format numbers compactly in terms of an explicit power of 10, e.g. 0.34K
, 12,456 thousand
, 2,887 billion
, etc.@phensley/timezone
'integer'
and 'fraction'
digit types.'minus'
or 'plus'
.'exp'
.'05up'
'truncate'
. Use 'down'
.'scientific'
.'minus'
to 'sign'
fromWall
methods until stablecontext: ContextType
propertydateField
method to Calendars
apitimeZoneInfo
to Calendars
api, includes the exemplar city for each zoneeras()
, dayPeriods()
, etc) to accept optionscontext: ContextType
optionRelativeTimeWidthType
to DateFieldWidthType
displayName
to top-level of DateFields
schemaCalendar.timeZoneOffset
now has the correct signCLDR.General.parseLanguageTag
method{ group: true }
CLDR.Locales
namespace and merged methods into CLDR.General
LanguageIdType
CLDR.General.getLanguageDisplayName
CLDR
to an interface