module Data.Time.Zones.All (
toTZName,
fromTZName,
tzNameLabelMap,
tzByLabel,
tzByName,
TZLabel(..),
) where
import qualified Data.ByteString.Char8 as BS
import Data.Time.Zones.DB
import Data.Time.Zones.Read
import Data.Time.Zones.Types
import qualified Data.Vector as V
tzByLabel :: TZLabel -> TZ
tzByLabel = (v V.!) . fromEnum
where
v = V.fromList $ go tzDescriptions
go [] = []
go (Right (_, _, desc) : zs) = parseOlson desc : go zs
go (Left _ : zs) = go zs
tzByName :: BS.ByteString -> Maybe TZ
tzByName n = tzByLabel `fmap` fromTZName n