Valery Ushakov <u...@stderr.spb.ru> wrote: > Wolfgang Solfrank <wolfg...@solfrank.net> wrote: > >>> "first $WEEKDAY of next month". I am at a loss how to do this with >>> NetBSD's date(1). >> >> Thanks for the explanation. >> >> Ok, let's try with a double invocation: >> >> $ date -d "$(date -d '+1 month' '+%m/01/%C%y') sat" >> Sat Aug 1 00:00:00 CEST 2020 > > Alas... > > for day in Mon Tue Wed Thu Fri Sat Sun; do > echo $day = "$(date -d "$(date -d '+1 month' '+%m/01/%C%y') $day")" > done > > Mon = Sat Aug 1 00:00:00 MSK 2020 [...]
>From a qucik rts, it looks like it's not possible, or at least not via this attack vector: if (param.yyHaveDay && !param.yyHaveDate) { tod = RelativeDate(Start, param.yyDayOrdinal, param.yyDayNumber); where RelativeDate is the code that handles things like "last tue", yyHaveDay is the flag that we have that clause (i.e. day number and ordinal are valid) but yyHaveDate is the flag that we have a date specified, so if both are given, that code is not called. The rhs of that test can be dropped it seems. If yyHaveDate is true, we would parse the date (Start) first and then apply the relative shift. Running the above loop with LD_PRELOAD=.../parsedate.so Mon = Mon Aug 3 00:00:00 MSK 2020 Tue = Tue Aug 4 00:00:00 MSK 2020 Wed = Wed Aug 5 00:00:00 MSK 2020 Thu = Thu Aug 6 00:00:00 MSK 2020 Fri = Fri Aug 7 00:00:00 MSK 2020 Sat = Sat Aug 1 00:00:00 MSK 2020 Sun = Sun Aug 2 00:00:00 MSK 2020 -uwe