Day home Documentation
Day Key Concepts

Dates like we used them in the real world

May 2015 is a real-world date. It's not 00:01 on the 1st May 2015 in some timezone. (Or 23:01 30th March when you're in/out of summer-time!) May is 31 bright spring days. All of them.

You're filling a personal injury insurance claim: When did injury start? is easy, but what if you're still getting treatment? What do you put in the finish date box? D/a/y lets you put 'not yet' which is the only accurate answer. (And D/a/y also knows how to do calculations using that value.)

When did you have a particular vaccination? How are you with YY/MM/DD for 30-ish years ago? Depending on the application a guessed year or Not-known or A long time ago might be appropriate.

Your project is delayed a month so how do you add one month to Jan 31st? (2015 or 2016) D/a/y has a clear specification for the slippery and elastic matter of months.

17th September is a real world date, your birthday perhaps. Talking of birthdays, when is the new baby due?

Don't use Javascript Date unless you need time as well, and even then you're still probably better-off mostly using D/a/y

Overview of types of D/a/y

Calendar dayYear, month and day or year and month or just a year
Not knownWe simply don't know. (Not the same thing as Not valid)
Not validWe've found some logical error. (Not the same thing as Not known)
Beginning of timeWe don't have data going back beyond a certain point
End of timeOngoing. A very common pattern in real-world applications
FloatingA month or a month and a day. Start of tax years for example
IntervalNumeric values of days, months and years used when comparing or shifting days
Not valid intervalSomething went wrong with calculations
Abstract values are a frequent occurence when dealing with real-world data. Not yet is an essential value in any system. The Day type End-of-Time would probably be used here as we're talking about some ending. It's not some arbitary future date but a defined token which can be used in everyday calculations. What value should we use in the 'date_married' field for a single person? How about Not-valid. Day calculations will immediately recognise this as an unsuitable input and provide a Not-valid output. What value should we use in the 'date_married' field for a married person where we don't have the information? How about Not-known. This is conceptually very different from Not-valid. Day calculations will probably cascade results of NK to NK and NV to NV.
Intervals are very close cousins of 𝔻 objects. More on this dichotomy elsewhere.

Example of D/a/y calculations

How old are you?Today - 18 October 1960 You could be tempted to use Javascript Date to do this sum... Oh but you've got a number of milliseconds which you now need to convert to years months and days. Using Day you'll do something like
var age = dToday.Difference(dBorn); then age.ToString() for + 44y 6m 12d
How old are you?Today - 1960 Oh dear! 1960 is a real-world date but we've got two problems.
(1) Trying to do this with Javascript means coercing '1960' to '1 Jan 1960'
(2) Then it gives us a result with false (day) precision.
Day would subtract 1960 from 2015 say and report that it had an answer only accurate to years.
How long since you left school?Today - June 1978Clearly without a day we're only able to calculate to monthly precision. That's no problem for Day
How long since the battle of Hastings?Today - 1066Similar problem. Day will tell us 949 years
How long was/is your arm in plaster?Today - 12 June 2015The 'Today' value is a very common input. In this case we can do a simple sum with 'Today' meaning 'so far'.
What is 31st January 2015 plus one month?Shennanigans!28 Feb 2015
What is 28th January 2015 plus one month?Shennanigans!27 Feb 2015
When is the end of the tax year?4th AprilNo year! We call this a floating date. Happy birthday!

Frequently asked questions

How are D/a/ys stored?32-bit integers or easy translations to database or Javascript dates
What about internationalisation?Easy to edit dictionaries are part of the Day architecture
What are limits?4095 BC to 4095 AD
Is it tested?There's a test suite available for download.
Is it free?Yes
Is it available?Probably late summer 2015

Getting started

Dont get too excitedThese steps are to get you up and running. To get an application going is just a matter of copying a couple of files. Most of the operations you'll be doing with dates will be really boring but Day will handle the hard cases for you.

Browser

Server (node)

Internationalisation (i18n)

Familiarisation