From 511e78b86befd127155f95b788f1b2e7ed3964b3 Mon Sep 17 00:00:00 2001 From: Doug Coleman <doug.coleman@gmail.com> Date: Mon, 1 Sep 2008 11:43:57 -0500 Subject: [PATCH 1/4] remove memoized words from calendar. more docs --- basis/calendar/calendar-docs.factor | 27 +++++++++++++++++++++++++-- basis/calendar/calendar.factor | 6 +++--- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/basis/calendar/calendar-docs.factor b/basis/calendar/calendar-docs.factor index 8ee104d16e..64e3e1e004 100644 --- a/basis/calendar/calendar-docs.factor +++ b/basis/calendar/calendar-docs.factor @@ -278,8 +278,6 @@ HELP: time- } } ; -{ time+ time- } related-words - HELP: convert-timezone { $values { "timestamp" timestamp } { "duration" duration } { "timestamp" timestamp } } { $description "Converts the " { $snippet "timestamp" } "'s " { $snippet "gmt-offset" } " to the GMT offset represented by the " { $snippet "duration" } "." } @@ -299,3 +297,28 @@ HELP: >local-time "t" } } ; + +HELP: >gmt +{ $values { "timestamp" timestamp } { "timestamp" timestamp } } +{ $description "Converts the " { $snippet "timestamp" } " to the GMT timezone." } +{ $examples + { $example "USING: accessors calendar kernel prettyprint ;" + "now >gmt gmt-offset>> hour>> ." + "0" + } +} ; + +HELP: time* +{ $values { "obj1" object } { "obj2" object } { "obj3" object } } +{ $description "Multiplies each time slot of a timestamp or duration by a number and make a new duration from the result. Used in the implementation of " { $link before } "." } ; +{ time+ time- time* } related-words + +HELP: before +{ $values { "duration" duration } { "-duration" duration } } +{ $description "Negates a duration." } +{ $examples + { $example "USING: accessors calendar prettyprint ;" + "3 hours before now noon time+ hour>> ." + "9" + } +} ; diff --git a/basis/calendar/calendar.factor b/basis/calendar/calendar.factor index ff002bb16c..216d9aac66 100755 --- a/basis/calendar/calendar.factor +++ b/basis/calendar/calendar.factor @@ -3,7 +3,7 @@ USING: arrays kernel math math.functions namespaces sequences strings system vocabs.loader calendar.backend threads accessors combinators locals classes.tuple math.order -memoize summary combinators.short-circuit ; +summary combinators.short-circuit ; IN: calendar TUPLE: duration @@ -304,14 +304,14 @@ M: timestamp time- M: duration time- before time+ ; -MEMO: <zero> ( -- timestamp ) +: <zero> ( -- timestamp ) 0 0 0 0 0 0 instant <timestamp> ; : valid-timestamp? ( timestamp -- ? ) clone instant >>gmt-offset dup <zero> time- <zero> time+ = ; -MEMO: unix-1970 ( -- timestamp ) +: unix-1970 ( -- timestamp ) 1970 1 1 0 0 0 instant <timestamp> ; : millis>timestamp ( n -- timestamp ) From 361a7820cee16ab3e850fc516c5cb000d44923b6 Mon Sep 17 00:00:00 2001 From: Doug Coleman <doug.coleman@gmail.com> Date: Mon, 1 Sep 2008 11:48:22 -0500 Subject: [PATCH 2/4] remove calendar.backend --- basis/calendar/backend/authors.txt | 1 - basis/calendar/backend/backend.factor | 4 ---- basis/calendar/calendar.factor | 10 ++++++---- basis/calendar/unix/unix.factor | 4 ++-- basis/calendar/windows/windows.factor | 4 ++-- 5 files changed, 10 insertions(+), 13 deletions(-) delete mode 100755 basis/calendar/backend/authors.txt delete mode 100644 basis/calendar/backend/backend.factor diff --git a/basis/calendar/backend/authors.txt b/basis/calendar/backend/authors.txt deleted file mode 100755 index 7c1b2f2279..0000000000 --- a/basis/calendar/backend/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Doug Coleman diff --git a/basis/calendar/backend/backend.factor b/basis/calendar/backend/backend.factor deleted file mode 100644 index 56ccf9e6cc..0000000000 --- a/basis/calendar/backend/backend.factor +++ /dev/null @@ -1,4 +0,0 @@ -USING: kernel system ; -IN: calendar.backend - -HOOK: gmt-offset os ( -- hours minutes seconds ) diff --git a/basis/calendar/calendar.factor b/basis/calendar/calendar.factor index 216d9aac66..5710949af5 100755 --- a/basis/calendar/calendar.factor +++ b/basis/calendar/calendar.factor @@ -1,11 +1,13 @@ ! Copyright (C) 2007 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: arrays kernel math math.functions namespaces sequences -strings system vocabs.loader calendar.backend threads -accessors combinators locals classes.tuple math.order -summary combinators.short-circuit ; +strings system vocabs.loader threads accessors combinators +locals classes.tuple math.order summary +combinators.short-circuit ; IN: calendar +HOOK: gmt-offset os ( -- hours minutes seconds ) + TUPLE: duration { year real } { month real } @@ -305,7 +307,7 @@ M: duration time- before time+ ; : <zero> ( -- timestamp ) -0 0 0 0 0 0 instant <timestamp> ; + 0 0 0 0 0 0 instant <timestamp> ; : valid-timestamp? ( timestamp -- ? ) clone instant >>gmt-offset diff --git a/basis/calendar/unix/unix.factor b/basis/calendar/unix/unix.factor index 6383d4ec42..1da554e0f1 100644 --- a/basis/calendar/unix/unix.factor +++ b/basis/calendar/unix/unix.factor @@ -1,5 +1,5 @@ -USING: alien alien.c-types arrays calendar.backend -kernel structs math unix.time namespaces system ; +USING: alien alien.c-types arrays calendar kernel structs +math unix.time namespaces system ; IN: calendar.unix : get-time ( -- alien ) diff --git a/basis/calendar/windows/windows.factor b/basis/calendar/windows/windows.factor index b621d3bde3..508cbb0a49 100755 --- a/basis/calendar/windows/windows.factor +++ b/basis/calendar/windows/windows.factor @@ -1,5 +1,5 @@ -USING: calendar.backend namespaces alien.c-types system -windows windows.kernel32 kernel math combinators ; +USING: calendar namespaces alien.c-types system windows +windows.kernel32 kernel math combinators ; IN: calendar.windows M: windows gmt-offset ( -- hours minutes seconds ) From 4bac2b003ce31c82a3bac0236983f2b172115502 Mon Sep 17 00:00:00 2001 From: Doug Coleman <doug.coleman@gmail.com> Date: Mon, 1 Sep 2008 11:50:05 -0500 Subject: [PATCH 3/4] remove calendar.backend from using --- basis/calendar/calendar-docs.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/calendar/calendar-docs.factor b/basis/calendar/calendar-docs.factor index 64e3e1e004..127dc4c60a 100644 --- a/basis/calendar/calendar-docs.factor +++ b/basis/calendar/calendar-docs.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: arrays kernel math strings help.markup help.syntax -calendar.backend math.order ; +math.order ; IN: calendar HELP: duration From e78a3486760999ed84ecf132b4f566324cb028a8 Mon Sep 17 00:00:00 2001 From: Doug Coleman <doug.coleman@gmail.com> Date: Mon, 1 Sep 2008 12:00:14 -0500 Subject: [PATCH 4/4] remove gvim.backend --- basis/editors/gvim/backend/authors.txt | 1 - basis/editors/gvim/backend/backend.factor | 4 ---- basis/editors/gvim/backend/tags.txt | 1 - basis/editors/gvim/gvim.factor | 4 +++- basis/editors/gvim/unix/unix.factor | 2 +- basis/editors/gvim/windows/windows.factor | 2 +- 6 files changed, 5 insertions(+), 9 deletions(-) delete mode 100755 basis/editors/gvim/backend/authors.txt delete mode 100644 basis/editors/gvim/backend/backend.factor delete mode 100644 basis/editors/gvim/backend/tags.txt diff --git a/basis/editors/gvim/backend/authors.txt b/basis/editors/gvim/backend/authors.txt deleted file mode 100755 index 7c1b2f2279..0000000000 --- a/basis/editors/gvim/backend/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Doug Coleman diff --git a/basis/editors/gvim/backend/backend.factor b/basis/editors/gvim/backend/backend.factor deleted file mode 100644 index e2e2f0626e..0000000000 --- a/basis/editors/gvim/backend/backend.factor +++ /dev/null @@ -1,4 +0,0 @@ -USING: io.backend ; -IN: editors.gvim.backend - -HOOK: gvim-path io-backend ( -- path ) diff --git a/basis/editors/gvim/backend/tags.txt b/basis/editors/gvim/backend/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/editors/gvim/backend/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/editors/gvim/gvim.factor b/basis/editors/gvim/gvim.factor index 041f3db675..4cc9de17a1 100755 --- a/basis/editors/gvim/gvim.factor +++ b/basis/editors/gvim/gvim.factor @@ -1,10 +1,12 @@ USING: io.backend io.files kernel math math.parser namespaces sequences system combinators -editors.vim editors.gvim.backend vocabs.loader ; +editors.vim vocabs.loader ; IN: editors.gvim SINGLETON: gvim +HOOK: gvim-path io-backend ( -- path ) + M: gvim vim-command ( file line -- string ) [ gvim-path , swap , "+" swap number>string append , ] { } make ; diff --git a/basis/editors/gvim/unix/unix.factor b/basis/editors/gvim/unix/unix.factor index 3b8f7454c1..82b6bf199d 100644 --- a/basis/editors/gvim/unix/unix.factor +++ b/basis/editors/gvim/unix/unix.factor @@ -1,4 +1,4 @@ -USING: io.unix.backend kernel namespaces editors.gvim.backend +USING: io.unix.backend kernel namespaces editors.gvim system ; IN: editors.gvim.unix diff --git a/basis/editors/gvim/windows/windows.factor b/basis/editors/gvim/windows/windows.factor index daf5409c94..8c4e1aaacb 100755 --- a/basis/editors/gvim/windows/windows.factor +++ b/basis/editors/gvim/windows/windows.factor @@ -1,4 +1,4 @@ -USING: editors.gvim.backend io.files io.windows kernel namespaces +USING: editors.gvim io.files io.windows kernel namespaces sequences windows.shell32 io.paths system ; IN: editors.gvim.windows