Closed jnioche closed 8 months ago
Thanks for the report. This is a rather lousy error message for it failing to understand the date on the command line. Currently you either have to pass a full ISO8601 date and time (something like 2023-01-01T00:00:00Z) or a negative number of minutes (say -1440) which will subtracted from the current time. It would be nice to improve the date handling and the documentation here.
I had tried '2023-01-01T00:00:00' so was just one Z short. Thanks for the explanation, just tried and it works fine. I'll see if I can understand what the code does and contribute a PR.
Should you want to attempt to fix the error messages the thing to do would be to replace the calls that currently map the error from the time
crate into strings, here and here with something a little more helpful:
.map_err(|_| format!("Couldn't the date format '{date}', ... some helpful"))
I also filed #4 for the specific case you attempted which seems useful to support.
Thanks @Mossop I really need to up my skills in Rust. FYI I am planning to write a library to facilitate querying the UK Carbon Intensity API. Ideally, this could then help enrich the data coming from Glowmarkt by giving an accurate estimate of the CO2 emissions for a user, based not on some generic average figure but on the actual carbon intensity in the region at the time of consumption.
Sounds like a useful project and the best way to learn is by doing! I'm by no means a Rust expert myself.
Should you want to attempt to fix the error messages the thing to do would be to replace the calls that currently map the error from the
time
crate into strings, here and here with something a little more helpful:.map_err(|_| format!("Couldn't the date format '{date}', ... some helpful"))
Implemented, see #5
Thanks for sharing your code. It is great to be able to query the data from the command line. I am getting an error message when trying to retrieve the readings
I am only starting programming in RUST so not quite able to work out what the problem is.
BTW I had to do
sudo apt install libssl-dev
in order to build the program. Maybe it would be worth mentioning it in the README?
Thanks!