Skip to content

Commit

Permalink
Fix duplicated ical uid bug
Browse files Browse the repository at this point in the history
  • Loading branch information
0rphee committed Jun 10, 2024
1 parent 0180379 commit ba80b5d
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/WriteiCal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ import Data.Map.Strict as M
import Data.Text qualified as TS
import Data.Text.Lazy qualified as TL
import Data.Time
import Data.Time.Clock.System
( systemToUTCTime, getSystemTime, systemToUTCTime )
import Data.Time.Calendar.Easter (sundayAfter)
import Data.Time.Clock.System
( getSystemTime
, systemToUTCTime
)
import Prettyprinter (pretty)
import Text.ICalendar hiding (Class)
import Types

Expand Down Expand Up @@ -104,9 +107,19 @@ toVCal weekStartDay subjects = do
}
)
where
classIntervalToText :: Class -> TL.Text
classIntervalToText c = start <> "-" <> end
where
start = TL.pack $ show $ pretty c.classInterval.intervalStartingTime
end = TL.pack $ show $ pretty c.classInterval.intervalEndTime

getUidText :: IO TL.Text
getUidText = do
time <- TL.pack . formatTime defaultTimeLocale "%C:%y:%m:%dT:%H:%M:%S:%qZ" . systemToUTCTime <$> getSystemTime
time <-
TL.pack
. formatTime defaultTimeLocale "%C:%y:%m:%dT:%H:%M:%S:%qZ"
. systemToUTCTime
<$> getSystemTime
let res =
TL.fromStrict subId
<> "-"
Expand All @@ -115,6 +128,7 @@ toVCal weekStartDay subjects = do
<> TL.pack (show $ getClassDayOffset individualClass)
<> "-"
<> time
<> classIntervalToText individualClass
pure res

dayOfClass :: Day
Expand Down

0 comments on commit ba80b5d

Please sign in to comment.