Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect due date #3

Closed
grimnight opened this issue Oct 19, 2024 · 12 comments
Closed

Incorrect due date #3

grimnight opened this issue Oct 19, 2024 · 12 comments

Comments

@grimnight
Copy link

With config:

[template]
  due_today = "today"
  due_tomorrow = "tomorrow"
  due_in = "in {{.AgeOrDays}} days"
  date_format_short = "02/01"
  date_format = "02/01/2006"
  Birthday0 = "[{{.Name}}]'s birthday is {{.Due}}! {{.Date}}\n"
  Birthday = "[{{.Name}}] is turning {{.AgeOrDays}} years old {{.Due}}! {{.Date}}"
  Reminder = "[{{.Name}}] is due {{.Due}}! {{.Date}} - {{.Due}}"

[[Reminder]]
  Name = "Example Event"
  Date = "21/10/2024"
  Message = "Don't forget about the Example Event!"

I get output:

❯ date +%d/%m/%Y
20/10/2024

❯ britto
[Example Event] is due in 2 days! 21/10 - in 2 days
Don't forget about the Example Event!

Which should say tomorrow.
Also, should Message be part of template section?

PS. Sorry for spamming so many issues in such a short time.

@xplshn
Copy link
Owner

xplshn commented Oct 20, 2024

Also, should Message be part of template section?

I don't think so, Message is per-event, you can add Message to any event, birthday or reminder.

Which should say tomorrow.

Will get to work on this, thanks for reporting

Britto is not something that I use a lot, its there on my terminal config just so I don't forget about birthday's, the rest are just niceties that I thought would be great. So sorry for so many inconveniences

@xplshn
Copy link
Owner

xplshn commented Oct 20, 2024

Fixed!

@xplshn xplshn closed this as completed Oct 20, 2024
@grimnight
Copy link
Author

Sorry if I was unclear.
I meant adding Message as a part of the template string, making it possible to have one line per event/birthday.

@grimnight
Copy link
Author

Reminders seem to work correctly now.
Unfortunately birthdays aren't shown, at all.

@xplshn
Copy link
Owner

xplshn commented Oct 20, 2024

Sorry if I was unclear. I meant adding Message as a part of the template string, making it possible to have one line per event/birthday.

I'm not sure I understand what you mean........................... Please show me an example.

@xplshn
Copy link
Owner

xplshn commented Oct 20, 2024

Reminders seem to work correctly now. Unfortunately birthdays aren't shown, at all.

That's kind of odd, they do work on my PC, let me check if there are any logic errors in the code
EDIT: Dumb mistake spotted, I should get some sleep before pushing code to any of my repos 😢

@grimnight
Copy link
Author

I thought of something like:

[template]
  Birthday = "[{{.Name}}] is turning {{.AgeOrDays}} years old {{.Due}}! {{.Date}} - {{.Message}}"
  Reminder = "[{{.Name}}] is due {{.Due}}! {{.Date}} - {{.Due}} - {{.Message}}"

or:

[template]
  Birthday = "[{{.Name}}] is turning {{.AgeOrDays}} years old {{.Due}}! {{.Date}}\n{{.Message}}"
  Reminder = "[{{.Name}}] is due {{.Due}}! {{.Date}} - {{.Due}}\n{{.Message}}"

If that makes sense.

@xplshn xplshn reopened this Oct 20, 2024
@grimnight
Copy link
Author

grimnight commented Oct 20, 2024

After thinking on this some more, I think it might make more sense if it was like this:

[template]
  FormattedMessage = " - {{.Message}}"
  Birthday = "[{{.Name}}] is turning {{.AgeOrDays}} years old {{.Due}}! {{.Date}}{{.FormattedMessage}}"
  Reminder = "[{{.Name}}] is due {{.Due}}! {{.Date}} - {{.Due}}{{if .Message }}{{.FormattedMessage}}{{end}}"

or:

[template]
  FormattedMessage = "\n{{.Message}}"
  Birthday = "[{{.Name}}] is turning {{.AgeOrDays}} years old {{.Due}}! {{.Date}}{{.FormattedMessage}}"
  Reminder = "[{{.Name}}] is due {{.Due}}! {{.Date}} - {{.Due}}{{if .Message }}{{.FormattedMessage}}{{end}}"

Edit: Added {{if .Message }}{{.FormattedMessage}}{{end}}

@xplshn xplshn closed this as completed Oct 20, 2024
@grimnight
Copy link
Author

Just compiled and works for me.
Thank you for making Britto.

@grimnight
Copy link
Author

Sorry to bother you again.

Seems this issue isn't done quite yet.

~
❯ date +%d/%m/%Y
20/10/2024

~
❯ britto
[Example Event 1] is due today! 21/10/2024
[Example Event 2] is due in 3 days! 24/10/2024

@xplshn xplshn reopened this Oct 20, 2024
@xplshn
Copy link
Owner

xplshn commented Oct 20, 2024

Mind sending your entire config?

EDIT: Go's time library is very confusing, date formats are 02, which is month, 01 which is day and 2006 which is the year, I think I've found the issue in the function that parses dates
EDIT2: And also, I did not account for time differences :-"

@xplshn
Copy link
Owner

xplshn commented Oct 20, 2024

image

@xplshn xplshn closed this as completed Oct 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants