This commit is contained in:
@@ -58,6 +58,7 @@ TODO: LOCALIZATION
|
|||||||
|
|
||||||
- TODO: get time zone from browser with user override option
|
- TODO: get time zone from browser with user override option
|
||||||
- use browser default unless overridden
|
- use browser default unless overridden
|
||||||
|
- Intl.DateTimeFormat().resolvedOptions().timeZone
|
||||||
|
|
||||||
- How to handle dates and times
|
- How to handle dates and times
|
||||||
- All dates stored in UTC format at server and transmitted that way
|
- All dates stored in UTC format at server and transmitted that way
|
||||||
@@ -66,7 +67,7 @@ TODO: LOCALIZATION
|
|||||||
- Client uses the built in browser tolocale* methods to display dates to user both in their desired format and desired time zone, i.e. NO HOUR ADJUSTMENTS USED
|
- Client uses the built in browser tolocale* methods to display dates to user both in their desired format and desired time zone, i.e. NO HOUR ADJUSTMENTS USED
|
||||||
-- Proper way to definitevely display a date in desired time zone: DATE.toLocaleString('en-GB', { timeZone: 'UTC', dateStyle: "short",timeStyle: "short", hour12: false })
|
-- Proper way to definitevely display a date in desired time zone: DATE.toLocaleString('en-GB', { timeZone: 'UTC', dateStyle: "short",timeStyle: "short", hour12: false })
|
||||||
|
|
||||||
|
- SB able to ditch the dayjs library entirely once done!
|
||||||
|
|
||||||
- CURRENCY code, need to be able to set currency as a user option, no way to deduce it except maybe a default through deduction of locale
|
- CURRENCY code, need to be able to set currency as a user option, no way to deduce it except maybe a default through deduction of locale
|
||||||
- AM PM or 24 hour time sb a setting in locale
|
- AM PM or 24 hour time sb a setting in locale
|
||||||
|
|||||||
@@ -204,13 +204,19 @@ export default {
|
|||||||
// only how the user expects to see the page itself
|
// only how the user expects to see the page itself
|
||||||
//
|
//
|
||||||
// also for sake of future proofing and edge cases need to have it be manually settable as well
|
// also for sake of future proofing and edge cases need to have it be manually settable as well
|
||||||
// ############### TODO: modify both of these to put the user's manual override first in line (if there is one)
|
// ############### TODO: modify all of these to put the user's manual override first in line (if there is one)
|
||||||
getBrowserLanguages() {
|
getBrowserLanguages() {
|
||||||
return window.navigator.languages;
|
return window.navigator.languages;
|
||||||
},
|
},
|
||||||
getBrowserFirstLanguage() {
|
getBrowserFirstLanguage() {
|
||||||
return window.navigator.languages[0];
|
return window.navigator.languages[0];
|
||||||
},
|
},
|
||||||
|
///////////////////////////////////////////
|
||||||
|
// Get users default time zone
|
||||||
|
//
|
||||||
|
getTimeZoneName() {
|
||||||
|
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||||
|
},
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
// dynamically set the vuetify language elements from
|
// dynamically set the vuetify language elements from
|
||||||
// users localized text (am/pm etc)
|
// users localized text (am/pm etc)
|
||||||
|
|||||||
@@ -157,35 +157,28 @@ Vue.filter(
|
|||||||
var parsedDate = new Date(value);
|
var parsedDate = new Date(value);
|
||||||
//parsedDate now contains the correct value
|
//parsedDate now contains the correct value
|
||||||
//but any attempt to get it back out that isn't a UTC function will automatically convert to local perceived time zone
|
//but any attempt to get it back out that isn't a UTC function will automatically convert to local perceived time zone
|
||||||
|
|
||||||
var tzAdjustedDate = new Date();
|
|
||||||
tzAdjustedDate.setTime(
|
|
||||||
parsedDate.getTime() + locale.format().timeZoneOffset * 60 * 60 * 1000
|
|
||||||
);
|
|
||||||
|
|
||||||
// var localizedDate = dayjs
|
// DATE.toLocaleString('en-GB', { timeZone: 'UTC', dateStyle: "short",timeStyle: "short", hour12: false })
|
||||||
// .utc(value)
|
|
||||||
// .add(locale.format().timeZoneOffset, "hour")
|
|
||||||
// .toDate();
|
|
||||||
|
|
||||||
var ret = tzAdjustedDate.toLocaleString(
|
var ret = parsedDate.toLocaleString(
|
||||||
window.$gz.locale.getBrowserLanguages(),
|
window.$gz.locale.getBrowserLanguages(),
|
||||||
{
|
{
|
||||||
|
timeZone: locale.getTimeZoneName(),
|
||||||
dateStyle: "short",
|
dateStyle: "short",
|
||||||
timeStyle: "short",
|
timeStyle: "short",
|
||||||
hour12: locale.format().hour12
|
hour12: locale.format().hour12
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log("value");
|
// console.log("value");
|
||||||
console.log(value);
|
// console.log(value);
|
||||||
console.log("parsedDate");
|
// console.log("parsedDate");
|
||||||
console.log(parsedDate);
|
// console.log(parsedDate);
|
||||||
console.log("tzAdjustedDate");
|
// console.log("tzAdjustedDate");
|
||||||
console.log(tzAdjustedDate);
|
// console.log(tzAdjustedDate);
|
||||||
console.log("presented as:");
|
// console.log("presented as:");
|
||||||
console.log(ret);
|
// console.log(ret);
|
||||||
console.log("-------");
|
// console.log("-------");
|
||||||
//debugger;
|
//debugger;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user