index.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import { EraParser } from "./EraParser.js";
  2. import { YearParser } from "./YearParser.js";
  3. import { LocalWeekYearParser } from "./LocalWeekYearParser.js";
  4. import { ISOWeekYearParser } from "./ISOWeekYearParser.js";
  5. import { ExtendedYearParser } from "./ExtendedYearParser.js";
  6. import { QuarterParser } from "./QuarterParser.js";
  7. import { StandAloneQuarterParser } from "./StandAloneQuarterParser.js";
  8. import { MonthParser } from "./MonthParser.js";
  9. import { StandAloneMonthParser } from "./StandAloneMonthParser.js";
  10. import { LocalWeekParser } from "./LocalWeekParser.js";
  11. import { ISOWeekParser } from "./ISOWeekParser.js";
  12. import { DateParser } from "./DateParser.js";
  13. import { DayOfYearParser } from "./DayOfYearParser.js";
  14. import { DayParser } from "./DayParser.js";
  15. import { LocalDayParser } from "./LocalDayParser.js";
  16. import { StandAloneLocalDayParser } from "./StandAloneLocalDayParser.js";
  17. import { ISODayParser } from "./ISODayParser.js";
  18. import { AMPMParser } from "./AMPMParser.js";
  19. import { AMPMMidnightParser } from "./AMPMMidnightParser.js";
  20. import { DayPeriodParser } from "./DayPeriodParser.js";
  21. import { Hour1to12Parser } from "./Hour1to12Parser.js";
  22. import { Hour0to23Parser } from "./Hour0to23Parser.js";
  23. import { Hour0To11Parser } from "./Hour0To11Parser.js";
  24. import { Hour1To24Parser } from "./Hour1To24Parser.js";
  25. import { MinuteParser } from "./MinuteParser.js";
  26. import { SecondParser } from "./SecondParser.js";
  27. import { FractionOfSecondParser } from "./FractionOfSecondParser.js";
  28. import { ISOTimezoneWithZParser } from "./ISOTimezoneWithZParser.js";
  29. import { ISOTimezoneParser } from "./ISOTimezoneParser.js";
  30. import { TimestampSecondsParser } from "./TimestampSecondsParser.js";
  31. import { TimestampMillisecondsParser } from "./TimestampMillisecondsParser.js";
  32. /*
  33. * | | Unit | | Unit |
  34. * |-----|--------------------------------|-----|--------------------------------|
  35. * | a | AM, PM | A* | Milliseconds in day |
  36. * | b | AM, PM, noon, midnight | B | Flexible day period |
  37. * | c | Stand-alone local day of week | C* | Localized hour w/ day period |
  38. * | d | Day of month | D | Day of year |
  39. * | e | Local day of week | E | Day of week |
  40. * | f | | F* | Day of week in month |
  41. * | g* | Modified Julian day | G | Era |
  42. * | h | Hour [1-12] | H | Hour [0-23] |
  43. * | i! | ISO day of week | I! | ISO week of year |
  44. * | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
  45. * | k | Hour [1-24] | K | Hour [0-11] |
  46. * | l* | (deprecated) | L | Stand-alone month |
  47. * | m | Minute | M | Month |
  48. * | n | | N | |
  49. * | o! | Ordinal number modifier | O* | Timezone (GMT) |
  50. * | p | | P | |
  51. * | q | Stand-alone quarter | Q | Quarter |
  52. * | r* | Related Gregorian year | R! | ISO week-numbering year |
  53. * | s | Second | S | Fraction of second |
  54. * | t! | Seconds timestamp | T! | Milliseconds timestamp |
  55. * | u | Extended year | U* | Cyclic year |
  56. * | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
  57. * | w | Local week of year | W* | Week of month |
  58. * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
  59. * | y | Year (abs) | Y | Local week-numbering year |
  60. * | z* | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
  61. *
  62. * Letters marked by * are not implemented but reserved by Unicode standard.
  63. *
  64. * Letters marked by ! are non-standard, but implemented by date-fns:
  65. * - `o` modifies the previous token to turn it into an ordinal (see `parse` docs)
  66. * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
  67. * i.e. 7 for Sunday, 1 for Monday, etc.
  68. * - `I` is ISO week of year, as opposed to `w` which is local week of year.
  69. * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
  70. * `R` is supposed to be used in conjunction with `I` and `i`
  71. * for universal ISO week-numbering date, whereas
  72. * `Y` is supposed to be used in conjunction with `w` and `e`
  73. * for week-numbering date specific to the locale.
  74. */
  75. export var parsers = {
  76. G: new EraParser(),
  77. y: new YearParser(),
  78. Y: new LocalWeekYearParser(),
  79. R: new ISOWeekYearParser(),
  80. u: new ExtendedYearParser(),
  81. Q: new QuarterParser(),
  82. q: new StandAloneQuarterParser(),
  83. M: new MonthParser(),
  84. L: new StandAloneMonthParser(),
  85. w: new LocalWeekParser(),
  86. I: new ISOWeekParser(),
  87. d: new DateParser(),
  88. D: new DayOfYearParser(),
  89. E: new DayParser(),
  90. e: new LocalDayParser(),
  91. c: new StandAloneLocalDayParser(),
  92. i: new ISODayParser(),
  93. a: new AMPMParser(),
  94. b: new AMPMMidnightParser(),
  95. B: new DayPeriodParser(),
  96. h: new Hour1to12Parser(),
  97. H: new Hour0to23Parser(),
  98. K: new Hour0To11Parser(),
  99. k: new Hour1To24Parser(),
  100. m: new MinuteParser(),
  101. s: new SecondParser(),
  102. S: new FractionOfSecondParser(),
  103. X: new ISOTimezoneWithZParser(),
  104. x: new ISOTimezoneParser(),
  105. t: new TimestampSecondsParser(),
  106. T: new TimestampMillisecondsParser()
  107. };