Repository: moment/luxon
Pull request #716 (2020-05-26 18:41:31)

Add DATE_MED_WITH_WEEKDAY preset
Hi! I recently had a need for a date string with weekday, so I've added one. I noticed that a DATETIME_MED_WITH_WEEKDAY preset got added a while ago, so I followed that example.

Let me know if anything is missing!

jsf-clabot: [![CLA assistant check](https://cla.js.foundation/pull/badge/not_signed)](https://cla.js.foundation/moment/luxon?pullRequest=716) <br/>Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our [Contributor License Agreement](https://cla.js.foundation/moment/luxon?pullRequest=716) before we can accept your contribution.<br/>
GillesDebunne: Thanks for this contribution, this looks good to me.

Patch:
diff --git a/docs/formatting.md b/docs/formatting.md
index 74d3ba60..414f38ba 100644
--- a/docs/formatting.md
+++ b/docs/formatting.md
@@ -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                                                    |
diff --git a/src/datetime.js b/src/datetime.js
index c123b853..27089bf7 100644
--- a/src/datetime.js
+++ b/src/datetime.js
@@ -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}
diff --git a/src/impl/english.js b/src/impl/english.js
index 100d5796..633f5943 100644
--- a/src/impl/english.js
+++ b/src/impl/english.js
@@ -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):
diff --git a/src/impl/formats.js b/src/impl/formats.js
index 8c66b9a3..25210f6f 100644
--- a/src/impl/formats.js
+++ b/src/impl/formats.js
@@ -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,


Test patch:
diff --git a/test/datetime/degrade.test.js b/test/datetime/degrade.test.js
index 9bca381f..b2cdec38 100644
--- a/test/datetime/degrade.test.js
+++ b/test/datetime/degrade.test.js
@@ -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");