Reckoning Calendar
At some point I thought it would be fun to inflict maximum pain on myself and play with dates on purpose.
Here are my initial notes on the idea:
Uses:
As a constructor to create a calendar, timeline, both. ( new Reckoning({ranges: data, calendar: ops}) )
As a utility to get some data about dates Reckoning.mapRange({fromDate: xxx, toDate: xxx}) Reckoning.inRange({range: ref, date: ref})
Reckoning.parse(str) Reckoning.format(date/str) Reckoning.month(date/str) Reckoning.day(date/str) Reckoning.year(date/str)
All dates should use a common format for parsing and setting strings (moment style? - allow different formatters)
- Default should be a regex that accepts short-format y/m/d or y-m-d and outputs to y/m/d
Constructors:
Timeline, Calendar, Months, Controls, Days, Ranges
Timeline:
- Linear time displayed in units
- Each range is represented individually, each unit is a ‘cell’
- Start Date (? min-range)
- End Date (? max-range)
Calendar:
- Contains:
- Months
- Controls
- Weeks?
Months:
- Model
- string (from static map?)
- Contains:
- Weeks?
- Days
Days:
- Model
- key (y/m/d)
- date (js date object)
- shortDateString (if formatter provided - else date numerical - displays in calendar)
- longDateString (if formatter provided - else key - can return on click etc)
- VM
- ranges (matches - event key/name)
Controls:
- Month select
- View select
Ranges:
- Named states
- Contains:
- Legend
- Name
- Dates (array of strings)
- Events (array of objects)
- FromDate
- ToDate
- EveryDay
- EveryDate
- EveryMonth
Range Map:
-
fromDate && toDate dates array events = Create a lazy hash table with each individual date as keys, values contain date objects (potentially bad for multi-year ranges?) - create an array of date objects for the days between ‘from’ and ‘to’
- parse ‘dates’ into an array of date objects
- create a map - no duplicates, no null values
Numerical checks:
- fromDate && !toDate = (<) year then month then day
- !fromDate && toDate = (>) year then month then day
Skip every* if ‘from’ or ‘to’ was set and failed. Override and set to false if ‘from’ or ‘to’ passes but the every* fails
- everyDay = weds thurs fri etc (numerical - requires Date constructor)
- everyDate = numerical ===
- everyMonth = numerical ===
View:
- Table layout
- Month Select
-
Days have an ‘event key’ object?
- .is-date-[name]
How did it all work out?
Check it out yourself: