srid / neuron

Future-proof note-taking and publishing based on Zettelkasten (superseded by Emanote: https://github.com/srid/emanote)
https://neuron.zettel.page
GNU Affero General Public License v3.0
1.52k stars 150 forks source link

proposal: provide option for using UTC time #516

Closed lehmacdj closed 3 years ago

lehmacdj commented 3 years ago

I would like to use UTC timestamps for times in my zettelkasten so that changing timezones doesn't mess things up. Ideally this would make neuron create new notes using UTC time, and also interpret times in notes as UTC time wherever relevant.

Based on a cursory look at the codebase, it seems like everything uses LocalTime internally right now (e.g. DateMayTime). Probably the easiest option is to offer an override for the system provided timezone in neuron.dhall. This way one doesn't need to remember to pass a flag whenever using a zettelkasten using a different timezone than one's system defined one.

As far as implementation would go I would propose:

  1. instead of passing the time in NewCommand pass Maybe DateMayTime
  2. in newZettelFile fetch the current time as a default if there was no time passed via an option
  3. use timezone specified in Config (via timezone config option?) for determining what timezone to use for when fetching a time

I would be happy to send a PR if you would accept such a PR.

Longerterm it would be great to have more comprehensive timezone support, i.e.:

lehmacdj commented 3 years ago

@srid would it be possible to get some details on how this could be implemented as a plugin? It seems as though to some extent supporting time zones requires changing the data types used within the core? Specifically, it seems like it would require using either UTCTime or ZonedTime from Data.Time rather than just Day and TimeOfDay as DateMayTime currently does.

srid commented 3 years ago

@lehmacdj Sorry, I let this slip my radar.

Let's not worry about the plugin stuff. Your implementation approach sounds generally good to me, but isn't there a way we can avoid having to add a new config field? I like letting the full datetime value specify the timezone (+0000); if we do that, then we wouldn't need to worry about telling neuron.dhall as to how to interpret timezone?

lehmacdj commented 3 years ago

No worries!

Sure, we can avoid having a config field I think. We would

srid commented 3 years ago

Sounds good to me. PR welcome!

Sent from ProtonMail mobile

-------- Original Message -------- On Feb. 11, 2021, 11:13 p.m., Devin Lehmacher wrote:

No worries!

Sure, we can avoid having a config field I think. We would

  • write timezone by default when creating a new Zettel
  • interpret any time without a specified timezone as being in the current timezone when parsing

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

srid commented 3 years ago

Closing per https://neuron.zettel.page/next ... to further discuss this idea, post in Emanote repo.

(In particular, in Emanote you can access any arbitrary YAML metadata in the HTML templates)