Locale.js 4.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /**
  2. * @category Types
  3. * @summary A locale object. Default locale is `en-US`.
  4. *
  5. * @description
  6. * A locale object. Default locale is `en-US`.
  7. *
  8. * If you're using any of these date-fns, consider specifying a locale in options:
  9. *
  10. * - `differenceInCalendarWeeks`
  11. * - `eachWeekOfInterval`
  12. * - `endOfWeek`
  13. * - `format`
  14. * - `formatDistance`
  15. * - `formatDistanceStrict`
  16. * - `formatRelative`
  17. * - `getWeek`
  18. * - `getWeekOfMonth`
  19. * - `getWeeksInMonth`
  20. * - `getWeekYear`
  21. * - `isMatch`
  22. * - `isSameWeek`
  23. * - `isThisWeek`
  24. * - `lastDayOfWeek`
  25. * - `parse`
  26. * - `setDay`
  27. * - `setWeek`
  28. * - `setWeekYear`
  29. * - `startOfWeek`
  30. * - `startOfWeekYear`
  31. *
  32. * Read the Properties section below for more details.
  33. *
  34. * @typedef {Object} Locale
  35. *
  36. * @property {string} [code] - the locale code (ISO 639-1 + optional country code)
  37. * @property {Function} [formatDistance] - the function that takes a token
  38. * passed by `formatDistance` or `formatDistanceStrict` and payload,
  39. * and returns localized distance in words.
  40. * Required by `formatDistance` and `formatDistanceStrict`
  41. *
  42. * @property {Function} [formatRelative] - the function that takes a token
  43. * passed by `formatRelative` and two dates and returns the localized relative date format.
  44. * Required by `formatRelative`
  45. *
  46. * @property {Object} [localize] - the object with functions used to localize various values.
  47. * Required by `format` and `formatRelative`
  48. * @property {Function} localize.ordinalNumber - the function that localizes an ordinal number
  49. * @property {Function} localize.era - the function that takes 0 or 1 and returns localized era
  50. * @property {Function} localize.quarter - the function that localizes a quarter
  51. * @property {Function} localize.month - the function that localizes a month
  52. * @property {Function} localize.day - the function that localizes a day of the week
  53. * @property {Function} localize.dayPeriod - the function that takes one of the strings
  54. * 'am', 'pm', 'midnight', 'noon', 'morning', 'afternoon', 'evening' or 'night'
  55. * and returns localized time of the day
  56. *
  57. * @property {Object} [formatLong] - the object with functions that return localized formats
  58. * @property {Function} formatLong.date - the function that returns a localized long date format
  59. * @property {Function} formatLong.time - the function that returns a localized long time format
  60. * @property {Function} formatLong.dateTime - the function that returns a localized format of date and time combined
  61. *
  62. * @property {Object} [match] — the object with functions used to match and parse various localized values.
  63. * Required by `parse`
  64. * @property {Function} match.ordinalNumber - the function that parses a localized ordinal number
  65. * @property {Function} match.era - the function that parses a localized era
  66. * @property {Function} match.quarter - the function that parses a localized quarter
  67. * @property {Function} match.month - the function that parses a localized month
  68. * @property {Function} match.day - the function that parses a localized day of the week
  69. * @property {Function} match.dayPeriod - the function that parses a localized time of the day
  70. *
  71. * @property {Object} [options] - an object with locale options.
  72. * @property {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday).
  73. * Used by `differenceInCalendarWeeks`, `eachWeekOfInterval`, `endOfWeek`, `format`, `formatRelative`, `getWeek`, `getWeekOfMonth`,
  74. * `getWeeksInMonth`, `getWeekYear`, `isMatch`, `isSameWeek`, `isThisWeek`, `lastDayOfWeek`, `parse`, `setDay`,
  75. * `setWeek`, `setWeekYear`, `startOfWeek` and `startOfWeekYear`
  76. * @property {1|2|3|4|5|6|7} [options.firstWeekContainsDate=1] - the day of January,
  77. * which is always in the first week of the year.
  78. * Used by `format`, `getWeek`, `getWeekYear`, `isMatch`, `parse`, `setWeek`, `setWeekYear` and `startOfWeekYear`.
  79. *
  80. * @throws {RangeError} `locale` must contain `localize` property. Thrown by `format` and `formatRelative`
  81. * @throws {RangeError} `locale` must contain `formatLong` property. Thrown by `format` and `formatRelative`
  82. * @throws {RangeError} `locale` must contain `formatRelative` property. Thrown by `formatRelative`
  83. * @throws {RangeError} `locale` must contain `formatDistance` property. Thrown by `formatDistance` and `formatDistanceStrict`
  84. * @throws {RangeError} `locale` must contain `match` property. Thrown by `parse`
  85. */
  86. var Locale = {}
  87. module.exports = Locale