use local time instead of UTC, migrate.js, closes #131
Run `node migrate.js localtime data/*.json` to convert existing `time` entries from UTC to your local timezone.
This commit is contained in:
parent
bc8a89f365
commit
bb51fd8065
2 changed files with 37 additions and 3 deletions
6
util.js
6
util.js
|
|
@ -19,9 +19,9 @@ export const jsonDb = async file => {
|
|||
|
||||
export const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
|
||||
// date and time as UTC (no timezone offset) in nicely readable and sortable format, e.g., 2022-10-06 12:05:27.313
|
||||
export const datetime = (d = new Date()) => d.toISOString().replace('T', ' ').replace('Z', '');
|
||||
// same as datetime() but for local timezone, e.g., UTC + 2h for the above in DE
|
||||
export const datetimeLocal = (d = new Date()) => datetime(new Date(d.getTime() - new Date().getTimezoneOffset() * 60000));
|
||||
export const datetimeUTC = (d = new Date()) => d.toISOString().replace('T', ' ').replace('Z', '');
|
||||
// same as datetimeUTC() but for local timezone, e.g., UTC + 2h for the above in DE
|
||||
export const datetime = (d = new Date()) => datetimeUTC(new Date(d.getTime() - d.getTimezoneOffset() * 60000));
|
||||
export const filenamify = s => s.replaceAll(':', '.').replace(/[^a-z0-9 _\-.]/gi, '_'); // alternative: https://www.npmjs.com/package/filenamify - On Unix-like systems, / is reserved. On Windows, <>:"/\|?* along with trailing periods are reserved.
|
||||
|
||||
export const handleSIGINT = () => process.on('SIGINT', () => { // e.g. when killed by Ctrl-C
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue