Last active
February 10, 2021 05:48
-
-
Save bradparker/49d8a97247641cfefd5d07717983eb74 to your computer and use it in GitHub Desktop.
I should put this somewhere
This file contains hidden or 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
{ haskellPackages }: | |
haskellPackages.callCabal2nix "in-time-zone" ./. {} |
This file contains hidden or 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
cabal-version: >=1.10 | |
name: in-time-zone | |
version: 0.1.0.0 | |
author: Brad Parker | |
maintainer: [email protected] | |
build-type: Simple | |
executable in-time-zone | |
main-is: Main.hs | |
build-depends: base >=4.14 && <4.15, | |
time | |
default-language: Haskell2010 |
This file contains hidden or 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 Main where | |
import Control.Applicative ((<|>)) | |
import Data.Time (TimeZone, ZonedTime, utc, utcToZonedTime, zonedTimeToUTC) | |
import Data.Time.Format.ISO8601 (iso8601ParseM) | |
import System.Environment (getArgs) | |
inTimeZone :: TimeZone -> ZonedTime -> ZonedTime | |
inTimeZone timezone = utcToZonedTime timezone . zonedTimeToUTC | |
main :: IO () | |
main = do | |
[zoneString, timeString] <- getArgs | |
print =<< inTimeZone | |
<$> iso8601ParseM zoneString | |
<*> (iso8601ParseM timeString <|> utcToZonedTime utc <$> iso8601ParseM timeString) |
This file contains hidden or 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
import Distribution.Simple | |
main = defaultMain |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment