mymailisthis / bw-mmx-utils

1 stars 1 forks source link

Respecting timezones #1

Open chilio opened 2 months ago

chilio commented 2 months ago

Hey @mymailisthis,

your script is working very fine. Have you thought about adding timezone support?

FYI: At the moment (2024-09-11 00:59 localtime GMT+1) mmx-dayly-overview.js is returning 2024-09-09 instead of 2024-09-10 in my timezone (GMT+1)

mymailisthis commented 2 months ago

Sorry, I have been making some corrections and new features. I need to update the readme. I will think about your request. As I am living in a UTC country that was not a problem for me. About the remark you texted, yes, default date is 'yesterday' because the first goal was likewise chiadog send a report after midnight. However, you can add the following flags now:

--base=1024 (for TiB, PiB, etc) --output=console (to print in terminal instead of sending to telegram) --date=YYYY-MM-DD (default is yesterday, to send report at midnight; also can be used --date=live (I am using this with watch)) --blocks=1 (default is 0 - to show detailed blocks and relative efforts)

What I am using like I was using with chia farm summary is this: watch -n 30 './mmx-daily-overview.js --date=live --output=console --blocks=1'

Last commit was few minutes ago, please update. Also take a look at bw-mmx-lulu my mmx dog french name :P It will tail your log while sending you Block wins via telegram. Configuration also via .env. Also need to make a README.

chilio commented 2 months ago

Sure @mymailisthis, normally UTC is not a problem, but we live in different countries, that's why problems occur... And kind thanks for the additional options you provided...

mymailisthis commented 2 months ago

Hey @mymailisthis,

your script is working very fine. Have you thought about adding timezone support?

FYI: At the moment (2024-09-11 00:59 localtime GMT+1) mmx-dayly-overview.js is returning 2024-09-09 instead of 2024-09-10 in my timezone (GMT+1)

Expecting that your node server is running in localtime, please update the repository, and try again with --utc=false argument. Maybe you only can test it properly tomorrow at your 00h LT. Unfortunately my server is running in UTC tz and cannot make a good debug.

chilio commented 1 month ago

Hi @mymailisthis, sorry for delay in my reply. Actually I've tested this now, meaning even 1h 30m later than 00 and nothing changed. The script generates info not from yesterday, but from pre yesterday. I guess in my timezone when I run the script after 02:00 then it will produce output from yesterday

chilio commented 1 month ago

And indeed as I supposed this has happened. I see a very simple workaround. Create new .sh script with this content and name it as you like:

#!/bin/bash
date="$(date --date='yesterday' +'%Y-%m-%d')"
./mmx-daily-overview.js --output=telegram --date=$date
echo "MMX report generated for: $date."

Then maybe add new parameters and customize it to your needs, cause for now telegram is hardcoded. This way current date is read from the underlying local system and can be run from cron.

chilio commented 1 month ago

You can also find PR for this. Hope it helps.