Skip to content

Commit

Permalink
Add DATE_MED_WITH_WEEKDAY preset (#716)
Browse files Browse the repository at this point in the history
  • Loading branch information
saltire authored Jun 5, 2020
1 parent 72ccb80 commit c05a90f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/formatting.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Here's the full set of provided presets using the October 14, 1983 at 13:30:23 a
| --------------------------- | ------------------------------------------------------------------ | ---------------------------------------------------------- | -------------------------------------------------------- |
| DATE_SHORT | short date | 10/14/1983 | 14/10/1983 |
| DATE_MED | abbreviated date | Oct 14, 1983 | 14 oct. 1983 |
| DATE_MED_WITH_WEEKDAY | abbreviated date with weekday | Fri, Oct 14, 1983 | ven. 14 oct. 1983 |
| DATE_FULL | full date | October 14, 1983 | 14 octobre 1983 |
| DATE_HUGE | full date with weekday | Tuesday, October 14, 1983 | vendredi 14 octobre 1983 |
| TIME_SIMPLE | time | 1:30 PM | 13:30 |
Expand Down
8 changes: 8 additions & 0 deletions src/datetime.js
Original file line number Diff line number Diff line change
Expand Up @@ -1943,6 +1943,14 @@ export default class DateTime {
return Formats.DATE_MED;
}

/**
* {@link toLocaleString} format like 'Fri, Oct 14, 1983'
* @type {Object}
*/
static get DATE_MED_WITH_WEEKDAY() {
return Formats.DATE_MED_WITH_WEEKDAY;
}

/**
* {@link toLocaleString} format like 'October 14, 1983'
* @type {Object}
Expand Down
2 changes: 2 additions & 0 deletions src/impl/english.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ export function formatString(knownFormat) {
return "M/d/yyyy";
case stringify(Formats.DATE_MED):
return "LLL d, yyyy";
case stringify(Formats.DATE_MED_WITH_WEEKDAY):
return "EEE, LLL d, yyyy";
case stringify(Formats.DATE_FULL):
return "LLLL d, yyyy";
case stringify(Formats.DATE_HUGE):
Expand Down
7 changes: 7 additions & 0 deletions src/impl/formats.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ export const DATE_MED = {
day: n
};

export const DATE_MED_WITH_WEEKDAY = {
year: n,
month: s,
day: n,
weekday: s
};

export const DATE_FULL = {
year: n,
month: l,
Expand Down
1 change: 1 addition & 0 deletions test/datetime/degrade.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Helpers.withoutIntl("DateTime#toLocaleString supports known configurations", ()

expected.set(DateTime.DATE_SHORT, "8/6/2014");
expected.set(DateTime.DATE_MED, "Aug 6, 2014");
expected.set(DateTime.DATE_MED_WITH_WEEKDAY, "Wed, Aug 6, 2014");
expected.set(DateTime.DATE_FULL, "August 6, 2014");
expected.set(DateTime.DATE_HUGE, "Wednesday, August 6, 2014");
expected.set(DateTime.TIME_SIMPLE, "9:15 AM");
Expand Down

0 comments on commit c05a90f

Please sign in to comment.