Closed gregorybleiker closed 11 months ago
It is expected that the input time string will always be of format '2020-01-01' or '2020-01-01T22:11:00'
Yes, that's what the tests specify. Exercism's TDD approach forces you to treat the tests as the requirements. Or did you mean that you wished the instructions specified the input format?
when running locally, I got errors because my machine is in a timezone and not UTC
Did you notice the following in the instructions?
This exercise requires using GNU awk's Time Functions.
For the datetime parsing and formatting functions, be sure to set the UTC flag.
I think this is rather a 'medium' than a 'easy' exercise
Thank you for the feedback. I'll think about that.
Regardless of the discussion if tests are actually specs, for me personally it would have been clearer if the instructions to the exercise would have included that information. I'd be happy to make a PR.
Setting the UTC flag was not sufficient with my setup (manjaro on WSL). In either case (UTC flag set or unset), some tests failed. Only after setting the environment explicitly via TZ was it that all tests completed (this time with the UTC flag 0, because probably the local time was already interpreted as UTC).
I wonder if you're setting the DST flag in the datespec instead of setting the UTC flag in the function parameters.
@glennj I have tried all combinations (mktime with or without flag, datespec with or without DST). Any other suggestions?
Exercism has a Discord server and forum which are a really good place to ask for exercise help!!
@gregorybleiker are you also using the UTC flag in your strftime
call?
$ gawk 'BEGIN {date = "2023 7 30 12 34 56"
start = mktime(date, 1)
print strftime("%Y-%m-%d %H:%M:%S", start) # <<<
}'
2023-07-30 08:34:56
$ gawk 'BEGIN {date = "2023 7 30 12 34 56 0";
start = mktime(date, 1)
print strftime("%Y-%m-%d %H:%M:%S", start, 1) # <<<
}'
2023-07-30 12:34:56
@glennj that was it.
I think the exercise
gigaseconds
is missing a few important details.TZ='POSIX-fomat'
fixed that)