[commit: packages/time] master: time-zone test (3317848)
git at git.haskell.org
git at git.haskell.org
Fri Jan 23 22:53:09 UTC 2015
Repository : ssh://git@git.haskell.org/time
On branch : master
Link : http://git.haskell.org/packages/time.git/commitdiff/3317848eb12ef6881bd02614dd3baf1fd9664f1e
>---------------------------------------------------------------
commit 3317848eb12ef6881bd02614dd3baf1fd9664f1e
Author: Ashley Yakeley <ashley at semantic.org>
Date: Tue Apr 26 00:48:29 2005 -0700
time-zone test
darcs-hash:20050426074829-ac6dd-bb8e92544838e18afe1ec6020e8fb145cfaa56e7
>---------------------------------------------------------------
3317848eb12ef6881bd02614dd3baf1fd9664f1e
Makefile | 12 ++++++++++--
System/Time/Calendar.hs | 4 ++++
TimeZone.hs | 9 +++++++++
3 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 3a69e06..44f6935 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-default: TestFixed.diff CurrentTime.run TestTime.diff doc
+default: TestFixed.diff CurrentTime.run TestTime.diff TimeZone.diff doc
SRCS = Data/Fixed.hs System/Time/Clock.hs System/Time/TAI.hs System/Time/Calendar.hs
@@ -11,6 +11,12 @@ TestTime: TestTime.o libTimeLib.a
CurrentTime: CurrentTime.o libTimeLib.a
ghc $^ -o $@
+TimeZone: TimeZone.o libTimeLib.a
+ ghc $^ -o $@
+
+TimeZone.ref: FORCE
+ date +%z > $@
+
timestuff.o: timestuff.c timestuff.h
gcc -o $@ -c $<
@@ -20,7 +26,7 @@ libTimeLib.a: $(patsubst %.hs,%.o,$(SRCS)) timestuff.o
ranlib $@
clean:
- rm -rf CurrentTime TestTime TestFixed doc haddock *.out *.a *.o *.hi $(patsubst %.hs,%.o,$(SRCS)) $(patsubst %.hs,%.hi,$(SRCS)) Makefile.bak
+ rm -rf TimeZone TimeZone.ref CurrentTime TestTime TestFixed doc haddock *.out *.a *.o *.hi $(patsubst %.hs,%.o,$(SRCS)) $(patsubst %.hs,%.hi,$(SRCS)) Makefile.bak
doc: haddock/index.html
@@ -43,6 +49,8 @@ haddock/index.html: $(SRCS)
%.o: %.hs
ghc -c $< -o $@
+FORCE:
+
.SECONDARY:
depend: TestFixed.hs CurrentTime.hs TestTime.hs $(SRCS)
diff --git a/System/Time/Calendar.hs b/System/Time/Calendar.hs
index 683e017..ca10a6e 100644
--- a/System/Time/Calendar.hs
+++ b/System/Time/Calendar.hs
@@ -44,6 +44,10 @@ minutesToTimezone = MkTimeZone
hoursToTimezone :: Int -> TimeZone
hoursToTimezone i = minutesToTimezone (60 * i)
+instance Show TimeZone where
+ show (MkTimeZone t) | t < 0 = '-':(show (MkTimeZone (negate t)))
+ show (MkTimeZone t) = (show2 (div t 60)) ++ (show2 (mod t 60))
+
-- | The UTC time zone
utc :: TimeZone
utc = minutesToTimezone 0
diff --git a/TimeZone.hs b/TimeZone.hs
new file mode 100644
index 0000000..3d8b8bc
--- /dev/null
+++ b/TimeZone.hs
@@ -0,0 +1,9 @@
+module Main where
+
+import System.Time.Clock
+import System.Time.Calendar
+
+main :: IO ()
+main = do
+ zone <- getCurrentTimezone
+ putStrLn (show zone)
More information about the ghc-commits
mailing list