~ubuntu-branches/ubuntu/precise/ghc/precise

« back to all changes in this revision

Viewing changes to libraries/time/test/AddDays.hs

  • Committer: Bazaar Package Importer
  • Author(s): Joachim Breitner
  • Date: 2011-01-17 12:49:24 UTC
  • Revision ID: james.westby@ubuntu.com-20110117124924-do1pym1jlf5o636m
Tags: upstream-7.0.1
ImportĀ upstreamĀ versionĀ 7.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
{-# OPTIONS -Wall -Werror #-}
 
2
 
 
3
module Main where
 
4
 
 
5
import Data.Time.Calendar
 
6
 
 
7
days ::[Day]
 
8
days =
 
9
        [
 
10
        fromGregorian 2005 2 28,
 
11
        fromGregorian 2004 2 29,
 
12
        fromGregorian 2004 1 31,
 
13
        fromGregorian 2004 12 31,
 
14
        fromGregorian 2005 7 1,
 
15
        fromGregorian 2005 4 21,
 
16
        fromGregorian 2005 6 30
 
17
        ]
 
18
 
 
19
increments :: [Integer]
 
20
increments = [-10,-4,-1,0,1,7,83]
 
21
 
 
22
adders :: [(String,Integer -> Day -> Day)]
 
23
adders =
 
24
        [
 
25
        ("day",addDays),
 
26
        ("month (clip)",addGregorianMonthsClip),
 
27
        ("month (roll over)",addGregorianMonthsRollOver),
 
28
        ("year (clip)",addGregorianYearsClip),
 
29
        ("year (roll over)",addGregorianYearsRollOver)
 
30
        ]
 
31
 
 
32
resultDays :: [String]
 
33
resultDays = do
 
34
        (aname,adder) <- adders
 
35
        increment <- increments
 
36
        day <- days
 
37
        return ((showGregorian day) ++ " + " ++ (show increment) ++ " * " ++ aname ++ " = " ++ showGregorian (adder increment day))
 
38
 
 
39
main :: IO ()
 
40
main = do
 
41
        mapM_ putStrLn resultDays