lumeland / theme-simple-wiki

Lume theme to create a wiki to store your notes
https://lumeland.github.io/theme-simple-wiki/
MIT License
17 stars 5 forks source link

Timezone for footer #5

Closed RickCogley closed 9 months ago

RickCogley commented 9 months ago

Hi - I'm wondering if I can specify the timezone of the updated timestamp in the footer?

I notice it's possible in date-fns, but I don't know how to get it to work. https://date-fns.org/v3.2.0/docs/Time-Zones

oscarotero commented 9 months ago

I think you can set the TZ environment variable with the desired timezone.

RickCogley commented 9 months ago

If you mean on the build command like you showed me before, I did. But the template code doesn't pick that up automagically as far as I can tell.

oscarotero commented 9 months ago

It works fine to me:

deno task serve
imaxe
TZ=Europe/Helsinki deno task serve
imaxe
RickCogley commented 9 months ago

Figured it out. It was working on localhost, but not after pushing to Netlify. The problem was, if you simply specify like TZ=Europe/Helsinki deno task serve, I speculate that due to how Netlify (and maybe other build environments?) work, that isn't enough because of some kind of environment or sub-process spawning that is being done. However, if you "export" the TZ, so that it's fully available as an environment var like export TZ=Europe/Helsinki && deno task serve, it works. Here's the code I used specifically, which works for both localhost and up on Netlify:

{
  "importMap": "./import_map.json",
  "tasks": {
    "lume": "export TZ='Asia/Tokyo' && echo \"import 'lume/cli.ts'\" | deno run --unstable -A -",
    "build": "deno task lume",
    "serve": "deno task lume -s"
  },
  "compilerOptions": {
    "types": [
      "lume/types.ts"
    ]
  }
}

https://github.com/eSolia/help.esolia.pro/commit/11948f4acb33c733a69c717fae401f41f360ad42

RickCogley commented 9 months ago

Example in bash:

$ hoge="Hi"
$ echo $hoge
Hi
$ fuga="Bye"
$ export hoge
$ bash
bash-5.2$ echo $hoge
Hi
bash-5.2$ echo $fuga

bash-5.2$