module Model (Slot, Line,
isJunk, isDate, isTime, isBlankTime,
mkJunk,
mkDates,
mkTime,
month, day,
timeHeader, hours) where
-- MITSFS iPhone schedule pretty-printer
-- Copyright (C) 2008 Brian Sniffen
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, write to the Free Software Foundation, Inc.,
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
type Slot = Maybe String
data Line = Junk
| Dates Int Int -- Month, Day
| Time Int Slot Slot Slot Slot Slot Slot Slot
deriving (Read, Show)
isJunk Junk = True
isJunk _ = False
isDate (Dates _ _) = True
isDate _ = False
isTime (Time _ _ _ _ _ _ _ _) = True
isTime _ = False
isBlankTime (Time _ Nothing Nothing Nothing Nothing Nothing Nothing Nothing) = True
isBlankTime _ = False
mkJunk = Junk
mkDates m d = Dates m d
mkTime header ts@[sun,mon,tue,wed,thu,fri,sat] =
Time header sun mon tue wed thu fri sat
month (Dates m _) = m
day (Dates _ d) = d
timeHeader (Time h _ _ _ _ _ _ _) = h
hours (Time _ sun mon tue wed thu fri sat) =
[sun, mon, tue, wed, thu, fri, sat]