hackberrydev/alas

Wrong date when using `--insert-days`

Closed this issue · 4 comments

kwbr commented

When I run --insert-days in my timezone, at 9am the first day inserted is not today but the day before. Seems to be a timezone problem. Sometime later that day (did not investigate deeper) it correctly inserts the actual day.

$ date --iso-8601=minutes
2024-01-31T09:01+11:00
$ cat plan.md 
# My Plan

## Inbox
$ ./alas-x86_64-linux --insert-days 3 plan.md
Created backup.
$ cat plan.md
# My Plan

## Inbox

## 2024-02-01, Thursday

## 2024-01-31, Wednesday

## 2024-01-30, Tuesday

When combined with --insert-task it adds the task to the last day which is not what I would expect:

$ ./alas-x86_64-linux --insert-days 3 --insert-task "Hello World" plan.md
Created backup.
$ cat plan.md
# My Plan

## Inbox

## 2024-02-01, Thursday

## 2024-01-31, Wednesday

## 2024-01-30, Tuesday

- [ ] Hello World

I just found alas and like the idea very much. I would be happy to contribute a patch but I am not used to reading and understanding Lisp dialects.

Thank you for interest in Alas and for the detailed issue report.

I understand that this is almost a blocking issue. I can probably resolve it soon.

If you have some interest in learning Janet (the programming language) and contributing to the project, I can wait. Let me know your thoughts on that. Cheers.

kwbr commented

The fix seems to be simple. When getting the date with https://janet-lang.org/api/os.html#os/date we need to pass the local flag here

(let [today (os/date)]
.

Will try my best, adding a testcase and a fix. Wait for my patch.

👍 Sounds good.

Adding a test might not be easy in this case (as for other parts of the app). If you notice that adding a test is too "expensive", I'd be willing to accept a patch without a test.

@kwbr, the new version has been released. Thanks again!