A tiny (196B) JS utility to generate calendar views ↦
I love how much is squeezed into this truly tiny library.
import calendarize from 'calendarize';
// Week = [Sun, Mon, Tue, Wed, Thu, Fri, Sat]
const view = calendarize(new Date('2019-12-20'));
//=> [
//=> [ 1, 2, 3, 4, 5, 6, 7],
//=> [ 8, 9, 10, 11, 12, 13, 14],
//=> [15, 16, 17, 18, 19, 20, 21],
//=> [22, 23, 24, 25, 26, 27, 28],
//=> [29, 30, 31, 0, 0, 0, 0],
//=> ]
Check out the demo to see it in action.
Side note: the demo “reimplements” jQuery in one line:
const $ = document.querySelector.bind(document);
This reminds me of how I answered a question in our Slack recently about whether or not I’d use Umbrella JS again if starting a new project today.
if I were merely doing JS sprinkles I’d probably just write a few ‘ergonomics’ functions around querySelector and friends.
The web really has come a long way in a short time.
Discussion
Sign in or Join to comment or subscribe