hay-kot / homebox

Homebox is the inventory and organization system built for the Home User
https://hay-kot.github.io/homebox/
GNU Affero General Public License v3.0
2.71k stars 213 forks source link

Frontend does not parse the time zone properly #864

Closed Teraskull closed 7 months ago

Teraskull commented 8 months ago

First Check

Homebox Version

0.10.3

What is the issue you are experiencing?

Same problem described in #837, but cannot replicate in the demo instance. The demo instance properly shows "just now" on newly created items, and the API shows the timestamp in UTC.

My instance:

image

I tried setting up the TZ docker variable to my timezone, America/Chicago, but the frontend still defaults to UTC time.

The only way the timezone is taken into account is when I add the following to volumes:

volumes:
  - /etc/localtime:/etc/localtime:ro

But even then the frontend still shows "in 5 hours".

This is the API response for this location and it shows my time zone correctly:

// /api/v1/locations/79e263ef-f8ab-4b11-a58d-da48fa6d6e8d

{
  "id": "79e263ef-f8ab-4b11-a58d-da48fa6d6e8d",
  "name": "Test",
  "description": "",
  "createdAt": "2024-03-27T16:09:31.184901365-05:00",
  "updatedAt": "2024-03-27T16:09:31.184901648-05:00",
  "children": [

  ]
}

How can the maintainer reproduce the issue?

Be in a time zone other than UTC, or host homebox on a VPS that's not in UTC.

Deployment

Docker (Linux)

Deployment Details

homebox:
    container_name: homebox
    restart: unless-stopped
    ports:
      - 127.0.0.1:3100:7745
    environment:
      # - TZ=America/Chicago # If both this and localtime volume is set, API uses UTC time zone.
      - HBOX_OPTIONS_ALLOW_REGISTRATION=false
    volumes:
      - /root/docker-data/homebox/:/data
      - /etc/localtime:/etc/localtime:ro  # This sets the correct time zone for the API, only if TZ is not set.
    image: ghcr.io/hay-kot/homebox:latest
hay-kot commented 7 months ago

Closing since it's fixed in main (which is why it works on the demo site), will be in next release. Thanks!