go-naturaldate icon indicating copy to clipboard operation
go-naturaldate copied to clipboard

Support "6 month" with the future direction

Open NightMachinery opened this issue 5 years ago • 5 comments

Prerequisites

  • [x] I searched to see if the issue already exists.

Description

~/scripts/golang
❯ datenat.go 6 months from now
2021/03/03

~/scripts/golang
❯ datenat.go 6 month
2020/08/31

~/scripts/golang
❯ datenat.go 6 months
2020/08/31

~/scripts/golang
❯ datenat.go 6 months later
2020/08/31

Also, it's very jarring that the parsing succeeds on these examples. I think these should throw an error, as they contain important keywords like month that have been discarded.

NightMachinery avatar Aug 30 '20 22:08 NightMachinery

BTW, that datenat.go is a simple CLI wrapper.

NightMachinery avatar Aug 30 '20 22:08 NightMachinery

Same problem with 1 year, 2 years, etc.

NightMachinery avatar Aug 30 '20 22:08 NightMachinery

Getting months by name is also broken:

❯ datenat.go 'next February'
2021/03/03

~/Base/_Code/python/fin master
❯ datenat.go 'next November'
2020/12/01

~/Base/_Code/python/fin master
❯ datenat.go 'next December'
2020/12/31

NightMachinery avatar Aug 31 '20 00:08 NightMachinery

SGTM, happy to take a look at a PR, might be a little while until I can get to it

tj avatar Aug 31 '20 10:08 tj

Hi, just wanted to add that I ended up here looking for a library that could support this specific use case. I tried to get something to parse "5 minutes" as a Duration instead of Time, implemented it using this library and substracting time.Now(), but didn't work as I expected :(

MarioVilas avatar Apr 19 '23 14:04 MarioVilas