diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index 616ca73e..3c57102d 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -776,7 +776,6 @@ MID CENTURY MODERN TUNES - https://www.allmusic.com/album/ultra-lounge-vol-14-bo - BUILD 131 CHANGES OF NOTE - case 3946 at a glance wiki present implemented diff --git a/ayanova/src/api/locale.js b/ayanova/src/api/locale.js index 1c42b91e..95009bd1 100644 --- a/ayanova/src/api/locale.js +++ b/ayanova/src/api/locale.js @@ -79,82 +79,27 @@ export default { /////////////////////////////////////////// // Turn a utc date into a vueitfy calendar // schedule control compatible format - // localized: - // + // localized. + // For ease of use in schedule the epoch (milliseconds) is the best format // "It must be a Date, number of seconds since Epoch, or a string in the format of YYYY-MM-DD or YYYY-MM-DD hh:mm. Zero-padding is optional and seconds are ignored."" // // - utcDateToScheduleCompatibleFormatLocalized( - value, - timeZoneName, - languageName, - hour12 - ) { + utcDateToScheduleCompatibleFormatLocalized(value, timeZoneName) { if (!value) { - return ""; - } - if (!timeZoneName) { - timeZoneName = this.getResolvedTimeZoneName(); - } - if (!languageName) { - languageName = this.getResolvedLanguage(); - } - - if (!hour12) { - hour12 = this.getHour12(); - } - - //parse the date which is identified as utc ("2020-02-06T18:18:49.148011Z") - let parsedDate = new Date(value); - - //is it a valid date? - if (!(parsedDate instanceof Date && !isNaN(parsedDate))) { if (window.$gz.dev) { throw new Error( - `locale::utcDateToScheduleCompatibleFormatLocalized - Value '${value}' is not parseable` + `locale::utcDateToScheduleCompatibleFormatLocalized - Value is empty` ); } return null; } - //return this: - //YYYY-MM-DD hh:mm - - //https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatToParts - let formatter = new Intl.DateTimeFormat(languageName, { - year: "numeric", - month: "numeric", - day: "numeric", - hour: "numeric", - minute: "numeric", - hour12: false, - timeZone: timeZoneName - }); - const parts = formatter.formatToParts(parsedDate); - - let p = { year: null, month: null, day: null, hour: null, minute: null }; - parts.forEach(x => { - switch (x.type) { - case "year": - case "relatedYear": - p.year = x.value; - break; - case "month": - p.month = x.value; - break; - case "day": - p.day = x.value; - break; - case "hour": - p.hour = x.value; - break; - case "minute": - p.minute = x.value; - break; - } - }); - - return `${p.year}-${p.month}-${p.day} ${p.hour}:${p.minute}`; + return new Date( + //sv-SE is iso-8601 format so cleanest to parse accurately + new Date(value).toLocaleString("sv-SE", { + timeZone: timeZoneName + }) + ).getTime(); }, /////////////////////////////////////////// // Turn a utc date into a displayable diff --git a/ayanova/src/views/home-schedule.vue b/ayanova/src/views/home-schedule.vue index 07358993..24b5ed5c 100644 --- a/ayanova/src/views/home-schedule.vue +++ b/ayanova/src/views/home-schedule.vue @@ -2,6 +2,7 @@