From d8b963872b342f5406ae3ca38577b030a82be4b4 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Thu, 2 Feb 2012 19:47:05 -0800 Subject: [PATCH] calendar: today is now midnight. --- basis/calendar/calendar-docs.factor | 8 ++++++-- basis/calendar/calendar.factor | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/basis/calendar/calendar-docs.factor b/basis/calendar/calendar-docs.factor index a520eca53b..cb5ce20376 100644 --- a/basis/calendar/calendar-docs.factor +++ b/basis/calendar/calendar-docs.factor @@ -490,11 +490,15 @@ HELP: saturday HELP: midnight { $values { "timestamp" timestamp } { "new-timestamp" timestamp } } -{ $description "Returns a new timestamp that represents today at midnight, or the beginning of the day." } ; +{ $description "Returns a new timestamp that represents the day at midnight, or the beginning of the day." } ; HELP: noon { $values { "timestamp" timestamp } { "new-timestamp" timestamp } } -{ $description "Returns a new timestamp that represents today at noon, or the middle of the day." } ; +{ $description "Returns a new timestamp that represents the day at noon, or the middle of the day." } ; + +HELP: today +{ $values { "timestamp" timestamp } } +{ $description "Returns a timestamp that represents today at midnight." } ; HELP: beginning-of-month { $values { "timestamp" timestamp } { "new-timestamp" timestamp } } diff --git a/basis/calendar/calendar.factor b/basis/calendar/calendar.factor index b451cfcf05..2592e91322 100644 --- a/basis/calendar/calendar.factor +++ b/basis/calendar/calendar.factor @@ -416,8 +416,11 @@ M: timestamp day-name day-of-week day-names nth ; : noon ( timestamp -- new-timestamp ) midnight 12 >>hour ; inline +: today ( -- timestamp ) + now midnight ; inline + : beginning-of-month ( timestamp -- new-timestamp ) - midnight 1 >>day ; + midnight 1 >>day ; inline : end-of-month ( timestamp -- new-timestamp ) [ midnight ] [ days-in-month ] bi >>day ;