From 6d29acb7ebb1c771b20a5b13062bea94f7c4e64c Mon Sep 17 00:00:00 2001 From: djmaze Date: Fri, 7 Aug 2020 15:08:41 +0200 Subject: [PATCH] Bugfix: momentjs shortMonths can be array or function --- README.md | 10 +++++----- dev/prototype-date.js | 9 +++++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 99f86ac88..3036b969f 100644 --- a/README.md +++ b/README.md @@ -75,20 +75,20 @@ Things might work in Edge 15-18, Firefox 47-62 and Chrome 54-68 due to one polyf |admin.js |2.130.942 |1.216.173 | 485.481 | 298.376 | |app.js |4.184.455 |2.961.284 | 932.725 | 691.792 | |boot.js | 671.522 | 94.230 | 169.502 | 28.382 | -|libs.js | 647.614 | 458.564 | 194.728 | 139.408 | +|libs.js | 647.614 | 458.656 | 194.728 | 139.408 | |polyfills.js | 325.834 | 0 | 71.825 | 0 | -|TOTAL js |7.960.367 |4.730.251 |1.854.261 |1.157.958 | +|TOTAL js |7.960.367 |4.730.343 |1.854.261 |1.157.958 | |js/min/* |1.14.0 |native |gzip 1.14 |gzip | |--------------- |--------: |--------: |--------: |--------: | |admin.min.js | 252.147 | 156.868 | 73.657 | 44.788 | |app.min.js | 511.202 | 384.861 |140.462 |101.677 | |boot.min.js | 66.007 | 11.575 | 22.567 | 4.460 | -|libs.min.js | 572.545 | 413.893 |176.720 |129.076 | +|libs.min.js | 572.545 | 413.971 |176.720 |129.076 | |polyfills.min.js | 32.452 | 0 | 11.312 | 0 | -|TOTAL js/min |1.434.353 | 967.197 |424.718 |280.001 | +|TOTAL js/min |1.434.353 | 967.275 |424.718 |280.001 | -467.156 bytes (144.717 gzip) is not much, but it feels faster. +467.078 bytes (144.717 gzip) is not much, but it feels faster. |css/* |1.14.0 |native | diff --git a/dev/prototype-date.js b/dev/prototype-date.js index fa4fe6f1c..98255ffd5 100644 --- a/dev/prototype-date.js +++ b/dev/prototype-date.js @@ -5,10 +5,15 @@ w.moment = { defineLocale: (name, config)=>{ locale = config; - for (let i = 0; i < 12; ++i) Date.shortMonths[i] = config.monthsShort(i+1, 'MMM'); + const m = config.monthsShort; + if (Array.isArray(m)) { + Date.shortMonths = m; + } else for (let i = 0; i < 12; ++i) { + Date.shortMonths[i] = config.monthsShort({month:()=>i}, '-MMM-'); + } Date.longMonths = config.months, Date.longDays = config.weekdays; - Date.shortDays = config.weekdaysMin; // config.weekdaysShort + Date.shortDays = config.weekdaysMin; } };