malcommac / SwiftDate

🐔 Toolkit to parse, validate, manipulate, compare and display dates, time & timezones in Swift.
MIT License
7.61k stars 767 forks source link

Is there a type representing a "Date" as we use it in normal conversations--i.e. without time? #802

Open funct7 opened 2 years ago

funct7 commented 2 years ago

Joda-time has the notion of a LocalDate, which is date without time; basically, what we mean by date in normal day-to-day English. I'm wondering if the SwiftDate library has it.

I dug around a bit and am 99% sure there isn't, but just to be sure. If there isn't, do you guys have any plans to support it?

Thank you :)

alex-x-x-x-x commented 1 year ago

Check out https://github.com/malcommac/SwiftDate/blob/master/Sources/SwiftDate/DateRepresentable.swift @funct7

funct7 commented 1 year ago

@alex-x-x-x-x Thanks for the reference, but this doesn't really cut it.

For instance, if you have a coupon that is good until a certain day and are using a property with a type that really represents an "instance" in the time continuum, e.g. Date, the meaning is not really apparent. You'll either have to make it the midnight of the first "bad" date and check for less than or make it some arbitrary point in time of the last good date. Either way, it makes the code very confusing and unexpressive.

Sure it can be done, but that's like saying you only need a Int64 or TimeInterval because all use-cases can be covered. There's no need for time zones, date types, etc.