 : last-friday-of-month ( timestamp -- new-timestamp ) 5 last-day-this-month ;
 : last-saturday-of-month ( timestamp -- new-timestamp ) 6 last-day-this-month ;
 
+CONSTANT: day-predicates-array
+    { sunday? monday? tuesday? wednesday? thursday? friday? saturday? }
+
+: n>day-predicate ( string -- predicate )
+    day-predicates-array nth ;
+
+: n>day-abbreviation3 ( n -- string )
+    day-abbreviations3-array nth ; inline
+
+ERROR: not-a-day-abbreviation string ;
+
+: day-abbreviation3>n ( string -- n )
+    day-abbreviations3-hash ?at [ not-a-day-abbreviation ] unless ; inline
+
+: day-abbreviation3>predicate ( string -- predicate )
+    day-abbreviation3>n day-predicates-array nth ;
+
 : beginning-of-week ( timestamp -- new-timestamp )
     midnight sunday ;
 

! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays classes.tuple combinators
combinators.short-circuit kernel locals math math.functions
math.order sequences summary system vocabs vocabs.loader ;
IN: calendar

HOOK: gmt-offset os ( -- hours minutes seconds )

: day-abbreviation2 ( n -- string )
    day-abbreviations2 nth ; inline

CONSTANT: day-abbreviations3-array
    { "Sun" "Mon" "Tue" "Wed" "Thu" "Fri" "Sat" }

CONSTANT: day-abbreviations3-hash
    H{
        { "Sun" 0 } { "Mon" 1 } { "Tue" 2 } { "Wed" 3 }
        { "Thu" 4 } { "Fri" 5 } { "Sat" 6 }
    }

CONSTANT: average-month 30+5/12
CONSTANT: months-per-year 12
