closest-day ( timestamp n -- timestamp' )


Vocabulary
calendar.private

Inputs
timestampan object
nan object


Outputs
timestamp'an object


Definition


: closest-day ( timestamp n -- timestamp' )
[ dup day-of-week 7 swap - ] [ + 7 mod ] bi*
{ 0 1 2 3 -3 -2 -1 } nth days time+ ;