Skip to content

Instantly share code, notes, and snippets.

@bradparker
Last active February 10, 2021 05:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bradparker/49d8a97247641cfefd5d07717983eb74 to your computer and use it in GitHub Desktop.
Save bradparker/49d8a97247641cfefd5d07717983eb74 to your computer and use it in GitHub Desktop.
I should put this somewhere
{ haskellPackages }:
haskellPackages.callCabal2nix "in-time-zone" ./. {}
cabal-version: >=1.10
name: in-time-zone
version: 0.1.0.0
author: Brad Parker
maintainer: hi@bradparker.com
build-type: Simple
executable in-time-zone
main-is: Main.hs
build-depends: base >=4.14 && <4.15,
time
default-language: Haskell2010
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)
import Distribution.Simple
main = defaultMain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment