Et2Date: Handle formatting full month d-M-Y

Maybe we just pass all formatting off to flatpickr?
This commit is contained in:
nathan 2022-05-02 17:10:07 -06:00
parent ae73511958
commit cff1671f6f

View File

@ -17,6 +17,7 @@ import {dateStyles} from "./DateStyles";
import {LitFlatpickr} from "lit-flatpickr"; import {LitFlatpickr} from "lit-flatpickr";
import "flatpickr/dist/plugins/scrollPlugin.js"; import "flatpickr/dist/plugins/scrollPlugin.js";
import {holidays} from "./Holidays"; import {holidays} from "./Holidays";
import flatpickr from "flatpickr";
// Request this year's holidays now // Request this year's holidays now
holidays(new Date().getFullYear()); holidays(new Date().getFullYear());
@ -239,6 +240,11 @@ export function formatDate(date : Date, options = {dateFormat: ""}) : string
m: (date.getUTCMonth() < 9 ? "0" : "") + (date.getUTCMonth() + 1), m: (date.getUTCMonth() < 9 ? "0" : "") + (date.getUTCMonth() + 1),
Y: "" + date.getUTCFullYear() Y: "" + date.getUTCFullYear()
} }
if(dateformat.indexOf("M") != -1)
{
replace_map["M"] = flatpickr.formatDate(date, "M");
}
let re = new RegExp(Object.keys(replace_map).join("|"), "g"); let re = new RegExp(Object.keys(replace_map).join("|"), "g");
_value = dateformat.replace(re, function(matched) _value = dateformat.replace(re, function(matched)
{ {