Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define timezone for timestamps #19

Closed
baaswietse opened this issue Jul 27, 2020 · 4 comments
Closed

Define timezone for timestamps #19

baaswietse opened this issue Jul 27, 2020 · 4 comments

Comments

@baaswietse
Copy link

Is there any way to define your current timezone or an offset?
Right now the timestamps from the logger are 2 hours behind.

I couldn't find this in the docs.

Thanks.

@xpl
Copy link
Owner

xpl commented Jul 27, 2020

@baaswietse Now you can, I just added it:

log.configure ({
    time: {
        yes: true,
        format: 'locale',
        locale: 'en-US',
        options: { timeZone: 'America/Denver' }
    }
})

It is the same options as described in https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat

Time zones can be looked up here: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

P.S. You can also provide a custom printer, if the built-in formatter doesn't do the exact thing you need:

log.configure ({ time: { yes: true, print: date => { /* format the date as needed */ }})

@baaswietse
Copy link
Author

Thank you so much for the quick response!
Works like a charm :)

Just one side note, when defining the locale: 'be-NL' (I'm from Belgium).
The time string is formatted correctly but the date string isn't, we use this format: DD/MM/YYY, while in the logs it stays as MM/DD/YYY

@xpl
Copy link
Owner

xpl commented Jul 28, 2020

we use this format: DD/MM/YYY, while in the logs it stays as MM/DD/YYY

@baaswietse Try nl-BE instead of be-NL :)

@baaswietse
Copy link
Author

Oh wow, thank you sir!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants