EsperoTech / yaade

Yaade is an open-source, self-hosted, collaborative API development environment.
MIT License
1.56k stars 68 forks source link

added new timezone options and date variable assignment #156

Closed itsavaren closed 4 months ago

itsavaren commented 4 months ago

I am quite bad at javascript but I noodled and tried to implement the least impactful change that would respect the user's timezone in the timestamp. I'm american but I set it as en-GB as right now the variable is in UTC. feedback is welcome, or tell me to just make a feature request if its better for someone who knows what they're doing to handle it.

this is also my first ever contribution on github so I apologize if I did something wrong.

jonrosner commented 4 months ago

Hi, first of all thank you for your contribution it is highly appreciated.

Could you post examples of what it is that you are trying to achieve?

itsavaren commented 4 months ago

The timestamp for requests comes out like this: Mon, 20 May 2024 17:12:21 GMT

I was looking for a way to set the timezone of the Yaade container but every which way I set it, the timezone on those timestamps did not change.

I looked into the code and saw that the timestamp is generated with a Date().toUTCString() which seems from my research to always generate the timestamp in UTC.

My attempted contribution generates a timestamp string that respects the environments timezone offset, so it would instead show the localtime and GMT+/-Offset, GMT-4 for my time zone, for example.

It may just be American brain but I have trouble immediately recognizing which hour the GMT timestamp relates to in my local time zone, if it's been some hours since I did the last request.

Ideally I would imagine there could be some configuration setting in the profile to choose a timezone, but my skill in js is very, very poor and I would not know where to begin.

jonrosner commented 4 months ago

I see. I am fine with that change, but can you post some examples using your proposed time format? Best try out different timezones and see if all results yield the desired output.

itsavaren commented 4 months ago
eastern jst germany ukraine

screenshots from various timezones.

jonrosner commented 4 months ago

LGTM. We can merge this and maybe later add a profile configuration option for this. Thanks for you help.

jonrosner commented 4 months ago

Released on latest.