node-getenv icon indicating copy to clipboard operation
node-getenv copied to clipboard

Return environment variable as a date object

Open ledleds opened this issue 6 years ago • 4 comments

Thanks for this library, we find it very useful!

We sometimes have dates as environment variables and have been checking that when a date is given that it is valid everywhere we use your library. I thought maybe others could be doing this also so it might be useful to be within the library itself!

The new date function uses another library dayjs for date validation and returns a date object with the given value.

Please let me know what you think!

ledleds avatar Apr 09 '19 15:04 ledleds

Hi @ledleds, glad to hear you find this library useful!

I like the idea of being able to handle dates more easily. And I also think the code quality of your patchset is really good!

However I'm a bit reluctant with respect to adding a dependency (dayjs) which is much more complex than this tiny library on its own just for the sake of being able to parse/validate dates which will add.

Do you see any chance of extracting the logic behind dayjs().isValid() and inline it directly in this library here?

ctavan avatar Apr 09 '19 20:04 ctavan

Swapping Moment out for Dayjs may make sense. Dayjs has the same interface as Moment but is only 2kb: https://github.com/iamkun/dayjs

jshjohnson avatar Sep 06 '19 07:09 jshjohnson

I still would love to keep this basic module free of external dependencies . If you could inline the relevant functionality I‘d be happy to merge.

ctavan avatar Sep 06 '19 09:09 ctavan

@ledleds @jshjohnson any interest from your end of picking this up again and providing an implementation that works without adding dependencies?

ctavan avatar Oct 09 '19 10:10 ctavan