tempo icon indicating copy to clipboard operation
tempo copied to clipboard

feature: optional date arguments for functions

Open WilcoSp opened this issue 1 year ago • 4 comments

based on issue https://github.com/formkit/tempo/issues/56

is*, diff* and most other functions that use the date function could 1 or more arguments be made optional to allow using the current time (now) without needing to create new Date().

currently this draft has only isAfter, isBefore and diffMilliseconds to give an example how it could look. I would like to first discuss which other functions could allow for optional arguments to use the current time ('now') and how

current progress (ts, tests, jsdoc):

  • [x] is*
  • [x] diff*
  • [x] add*
  • [x] same*
  • [x] *end
  • [x] *start
  • [x] nearestDay
  • [x] monthDays
  • [x] dayOfYear
  • [x] yearDays
  • [x] offset
  • [x] fill
  • [x] createPartMap
  • [x] removeOffset
  • [x] tzDate

added:

  • [x] isPast
  • [x] isFuture

(the only part that only needs to be changed still is the website docs)

WilcoSp avatar May 12 '24 08:05 WilcoSp

@WilcoSp is attempting to deploy a commit to the Formkit Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar May 12 '24 08:05 vercel[bot]

@WilcoSp sorry for the delay. I think this looks great. If you flesh this out for the rest of the fns I’ll gladly merge it.

justin-schroeder avatar Jun 27 '24 01:06 justin-schroeder

hey @justin-schroeder it's not an issue, I was also busy the past month. When I've sometime (most likely on Wednesdays) I'll bring optional date arguments to other functions.

WilcoSp avatar Jun 30 '24 16:06 WilcoSp

@justin-schroeder all the functions where possible have given been optional date arguments (check top post for which ones have been changed).

I've also added isPast & isFuture as I think it would make the code more understandable than isAfter(date) or isBefore(date).

the only thing that needs to be still changed are the website docs for each function, I've looked a bit into how the website docs are made and if you want I could also change those if wanted or if you want you can change them.

WilcoSp avatar Jul 31 '24 09:07 WilcoSp

Thanks @WilcoSp!

justin-schroeder avatar Aug 21 '24 13:08 justin-schroeder