Created
August 31, 2011 07:35
-
-
Save Tarrasch/1183012 to your computer and use it in GitHub Desktop.
Extracting feed of a Google Calender for upcoming events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Test where | |
import Data.Time.RFC3339 | |
import Data.Time.LocalTime | |
import Data.Time.Calendar (addDays) | |
import Network.URL | |
main = do | |
putStrLn $ exportURL paramUrl | |
startTime <- getZonedTime >>= return . showRFC3339 | |
endTime <- getZonedTime >>= return . showRFC3339 . plusOneWeek | |
let completeUrl = (`add_param` ("start-min", startTime)) | |
. (`add_param` ("start-max", endTime)) | |
$ paramUrl | |
putStrLn $ exportURL completeUrl | |
where | |
Just basicUrl = importURL "https://www.google.com/calendar/feeds/pbtqihgenalb8s3eddsgeuo1fg%40group.calendar.google.com/public/basic" | |
paramUrl = basicUrl { url_params = [("max-results", "10"), ("orderby", "starttime"), ("sortorder", "ascending")] } | |
plusOneWeek :: ZonedTime -> ZonedTime | |
plusOneWeek (ZonedTime lt tz) = ZonedTime lt' tz | |
where lt' = lt { localDay = addDays 7 (localDay lt) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment