nobsun #7981(2008/11/07 03:12 GMT) [ Haskell ] Rating0/0=0.00
Time Zone の情報を取るのがすこしまわりくどいです MacOS X 10.5、ghc-6.10.1 ではうまくいっているようにみえますが、 summer timeの扱いがうまくいくかどうかは未確認です。 実行例 *Main> :main 現在の時刻は、2008年11月07日 18時03分09秒です。 グリニッジ標準時刻は、2008年11月07日 09時03分09秒です。 アメリカ・ロサンジェルスの時刻は、2008年11月07日 01時03分09秒です。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
module Main where import Data.Time import System.Locale import System.Posix.Env import qualified System.IO.UTF8 as U main :: IO () main = do hereTZ <- getCurrentTimeZone tzenv <- getEnv "TZ" setEnv "TZ" "America/Los_Angeles" True laTZ <- getCurrentTimeZone case tzenv of { Nothing -> unsetEnv "TZ"; Just tz -> setEnv "TZ" tz True } ct <- getCurrentTime mapM_ U.putStrLn $ zipWith (formatTime defaultTimeLocale) [herefmt,utcfmt,lafmt] $ flip map [hereTZ,utc,laTZ] $ flip utcToLocalTime ct herefmt = "現在の時刻は、%Y年%m月%d日 %H時%M分%S秒です。" utcfmt = "グリニッジ標準時刻は、%Y年%m月%d日 %H時%M分%S秒です。" lafmt = "アメリカ・ロサンジェルスの時刻は、%Y年%m月%d日 %H時%M分%S秒です。"
Rating0/0=0.00-0+
[ reply ]
nobsun
#7981()
[
Haskell
]
Rating0/0=0.00
Rating0/0=0.00-0+
[ reply ]