@@ -1,8 +1,9 @@
1{-# OPTIONS_HADDOCK hide #-}
1{-# OPTIONS_HADDOCK hide #-}
2-----------------------------------------------------------------------------
3-----------------------------------------------------------------------------
4-- Module : Data.Time.LocalTime.TimeZone.Olson.Types
5-- Module : Data.Time.LocalTime.TimeZone.Olson.Types
5−-- Copyright : Yitzchak Gale 2010
6+-- Copyright : Yitzchak Gale 2018
7-- Maintainer : Yitzchak Gale <gale@sefer.org>
8-- Maintainer : Yitzchak Gale <gale@sefer.org>
8-- Portability : portable
9-- Portability : portable
@@ -36,6 +37,9 @@ module Data.Time.LocalTime.TimeZone.Olson.Types
40+#if MIN_VERSION_base(4,11,0)
41+import Data.Semigroup (Semigroup(..))
39import Data.Monoid (Monoid(..))
43import Data.Monoid (Monoid(..))
40import Control.Monad (mplus)
44import Control.Monad (mplus)
@@ -71,6 +75,17 @@ data OlsonData =
72 deriving (Eq, Show)
76 deriving (Eq, Show)
78+#if MIN_VERSION_base(4,11,0)
79+instance Semigroup OlsonData where
80+ OlsonData a b c d <> OlsonData a' b' c' d' =
81+ OlsonData (a ++ map (shiftBy $ length b) a')
82+ (b ++ b') (c ++ c') (d `mplus` d')
84+ shiftBy n trans = trans {transIndex = n + transIndex trans}
86+instance Monoid OlsonData where
87+ mempty = OlsonData [] [] [] Nothing
74instance Monoid OlsonData where
89instance Monoid OlsonData where
75 mempty = OlsonData [] [] [] Nothing
90 mempty = OlsonData [] [] [] Nothing
76 mappend (OlsonData a b c d ) (OlsonData a' b' c' d') =
91 mappend (OlsonData a b c d ) (OlsonData a' b' c' d') =
@@ -78,6 +93,7 @@ instance Monoid OlsonData where
78 (b ++ b') (c ++ c') (d `mplus` d')
93 (b ++ b') (c ++ c') (d `mplus` d')
80 shiftBy n trans = trans {transIndex = n + transIndex trans}
95 shiftBy n trans = trans {transIndex = n + transIndex trans}
82-- | A @Transition@ represents a moment when the clocks change in a
98-- | A @Transition@ represents a moment when the clocks change in a
83-- timezone. It consists of a Unix timestamp value that indicates the
99-- timezone. It consists of a Unix timestamp value that indicates the