July 25, 2015 at 4:21 PM by Dr. Drang
A few days ago, Teddy Svoronos tweeted this request:
@TextExpander trying to get a work week snippet that populates mondays to fridays date (eg, 7/20/15 - 7/24/15) that works on ios. any tips?
— Teddy Svoronos (@tedsvo) Wed Jul 22 2015 6:07 PM
I was busy with paying work at the time, so naturally I stopped what I was doing and wasted some time working out a solution. This is it.
It gives the date range of the next working week in a format that Teddy probably doesn’t like at all. I sure don’t.
Mon Jul 27 2015 to Fri Jul 31 2015
strftime or its many descendants. Instead it has a bunch of
I copied the minified source code of
moment.js and pasted it into a new snippet that I gave the abbreviation
momentjslibrary, a name I’ll never use (except in this post).
With that in place, I can rewrite my next week snippet to give more compact output:
Calling this snippet inserts
7/27 to 7/31
I’m sure Moment.js has a cleaner way to define
nextMonday, but I find its documentation of the
day method ambiguous when it comes to the definitions of “last Monday,” “next Monday,” and “this Monday.” To avoid the ambiguity, I stuck with my old code in Lines 4 and 5.
By fiddling with the arguments to the