diff options
author | stuebinm | 2023-03-09 21:14:54 +0100 |
---|---|---|
committer | stuebinm | 2023-03-09 21:14:54 +0100 |
commit | f939da1301dd537330b5a66d157fe38b8c2ea8b3 (patch) | |
tree | ceacf1d421ea678daf3e9e713d117dd304a8a2f5 /vdv-server/VDV451.hs | |
parent | a1f8779a4774e1058c2a1142482bc8fd41fcbe5f (diff) |
vdv 452: apply some correctionsvdv452
Diffstat (limited to '')
-rw-r--r-- | vdv-server/VDV451.hs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/vdv-server/VDV451.hs b/vdv-server/VDV451.hs index 8e8a841..c1d0842 100644 --- a/vdv-server/VDV451.hs +++ b/vdv-server/VDV451.hs @@ -28,6 +28,7 @@ import Data.Time.Format.ISO8601 (formatShow) import Data.Data (Proxy (..)) import Data.Time.Calendar.MonthDay (monthAndDayToDayOfYear) import Codec.Archive.Zip (toEntry, emptyArchive, addEntryToArchive, Archive) +import Debug.Trace (trace) class ÖPNVEncode a where encode :: a -> ByteString @@ -47,19 +48,20 @@ instance ÖPNVEncode Text where a -> [a] instance ÖPNVEncode Day where - encode day = "\""+|crop 2 d|+"."+|crop 2 m|+"."+|crop 4 y|+"\"" + encode day = encode $ (fromInteger y*10000) + m*100 + d where (y,m,d) = toGregorian day + -- | for things which can be encoded as either string or number, --- this module defaults to strings. Add this newtype to the schema --- to make things encode as numbers instead. -newtype AsNumber a = AsNumber a +-- this module defaults to numbers. Add this newtype to the schema +-- to make things encode as strings instead. +newtype AsText a = AsText a -instance ÖPNVEncode (AsNumber Day) where - encode (AsNumber day) = - encode (d*1000000 + m*10000 + (fromInteger y `mod` 10000)) +instance ÖPNVEncode (AsText Day) where + encode (AsText day) = "\""+|crop 2 d|+"."+|crop 2 m|+"."+|crop 4 y|+"\"" where (y,m,d) = toGregorian day + instance ÖPNVEncode DiffTime where encode = C8.pack . formatTime defaultTimeLocale "\"%2H:%2M:%2S\"" @@ -148,7 +150,7 @@ data ÖPNVOptions = ÖPNVOptions öpnvSchnittstellenDaten :: forall a. ÖPNVDatum a => ÖPNVOptions -> UTCTime -> Vector a -> LB.ByteString öpnvSchnittstellenDaten ÖPNVOptions{..} time rows = LB.intercalate "\n" $ fmap mkRow [ [F MOD, Raw "DD.MM.YYYY", Raw "HH:MM:SS", Raw "free"] - , [F SRC, F öpnvSource, F (utctDay time), F (utctDayTime time) ] + , [F SRC, F öpnvSource, (F . AsText . utctDay) time, F (utctDayTime time) ] , [F CHS, F ("ISO8859-1" :: Text)] , [F VER, F öpnvProgramVersion] , [F IFV, F ("1.0" :: Text)] |