]> Git — Sourcephile - comptalang.git/blob - lib/Hcompta/Model/Date.hs
Ajout : Format.Ledger.Read.journal
[comptalang.git] / lib / Hcompta / Model / Date.hs
1 {-# LANGUAGE DeriveDataTypeable #-}
2 {-# LANGUAGE StandaloneDeriving #-}
3 {-# LANGUAGE TypeSynonymInstances #-}
4 {-# OPTIONS_GHC -fno-warn-orphans #-}
5 module Hcompta.Model.Date where
6
7 import Data.Data
8 import qualified Data.Time.LocalTime as Time (ZonedTime(..), utc, utcToZonedTime, zonedTimeToUTC)
9 import qualified Data.Time.Calendar as Time (Day)
10 import qualified Data.Time.Format as Time ()
11 import qualified Data.Time.Clock.POSIX as Time (posixSecondsToUTCTime)
12 import qualified Data.Time.Clock as Time (UTCTime)
13 import Data.Typeable ()
14
15 -- * The 'Date' type
16
17 type Date
18 = Time.ZonedTime
19 deriving instance Eq Date
20
21 nil :: Date
22 nil = Time.utcToZonedTime Time.utc $ Time.posixSecondsToUTCTime 0
23
24 data Interval
25 = Interval_None
26 | Interval_Days Int
27 | Interval_Weeks Int
28 | Interval_Months Int
29 | Interval_Quarters Int
30 | Interval_Years Int
31 | Interval_DayOfMonth Int
32 | Interval_DayOfWeek Int
33 -- Interval_WeekOfYear Int
34 -- Interval_MonthOfYear Int
35 -- Interval_QuarterOfYear Int
36 deriving (Data, Eq, Ord, Read, Show, Typeable)
37
38 type Smart
39 = (String, String, String)
40
41 data Span
42 = Span (Maybe Time.Day) (Maybe Time.Day)
43 deriving (Data, Eq, Ord, Read, Show, Typeable)
44
45 data Which
46 = Which_Primary
47 | Which_Secondary
48 deriving (Eq, Read, Show)
49
50 type Year
51 = Integer
52
53 -- * The 'UTC' type
54
55 type UTC = Time.UTCTime
56
57 to_UTC :: Date -> UTC
58 to_UTC = Time.zonedTimeToUTC