Open bretcope opened 10 years ago
I think I like the suggestion for this. It would be useful to me.
I have made a suggestion on a change to the proposed syntax. Ref https://github.com/schyntax/schyntax/issues/14.
In short I suggest that:
w
and week
is introduced, but enumerates according to the year. week(1)
is the first week in the year, week(-1)
is the last week in the year.wom
and weekOfMonth
are introduced to handle your original week
suggestion. fw
and fullWeek
complements week
and also relates to the year.fwom
and fullWeekOfMonth
are introduced to handle your original fullWeek
suggestion.There were some other suggestions in that post too that may be worth considering.
Weeks
I'm starting to think there needs to be a
weeks
expression to help express things like:The two above examples could be expressed as:
days(friday) weeks(1,3)
and(monday) weeks(-1)
Just like days of month, the week number could be expressed either as the number of weeks from the start of the month, or a negative number representing the number of weeks from the end of the month (1 and -1-indexed respectively).
Technically this is just syntactic sugar since both of the above examples could already be expressed as:
days(friday) dom(1..7, 15..21)
anddays(monday) dom(-7..-1)
but the
weeks
expression is far more readable and less error prone. It should also be rather trivial to implement.Weeks should have the aliases:
w
,week
,weeks
,weekofmonth
, andweeksofmonth
. Anticipating this expression was actually the reason for commit 1606847ca8bcd3036e28f006ad3a53f675c3a3f7 a couple months ago.Full Weeks
What would be more than simply syntax sugar would be to add a
fullWeeks
expression. Say you want something to run everyday for the first full week of a month, not simply the first seven daysfullweeks(1)
That would run everyday at midnight for seven days starting on the first Sunday of each month.
I can't think of any way to express this with the existing syntax so I think it would be a good addition to the language and still relatively trivial to implement.
Negative numbers would also be supported:
fullweeks(-1)
would run for seven days ending on the last Saturday of the month.Zero and negative zero would also be supported:
fullweeks(0)
would run any day of the month which is before the first Sunday, andfullweeks(-0)
would run any days of the month after the final Saturday.Aliases:
fw
,fullweek
,fullweeks
,fullweekofmonth
, andfullweeksofmonth
.