2016-11-11 2 views

답변

0

가능한 사용하는 간단한 time 기반 솔루션을 가진의 이익에

{-# LANGUAGE OverloadedStrings #-} 
import   Prelude 
import qualified Data.ByteString.Char8 as B 
import   Data.UnixTime 
import   Data.Int 
import   Data.Functor 

secToTimestampGMT :: Int32 -> [Char] 
secToTimestampGMT t = B.unpack $ formatUnixTimeGMT "%Y-%m-%d %H-%M-%S" $ UnixTime (fromIntegral t) 0 

secToTimestamp :: Int32 -> IO [Char] 
secToTimestamp t = B.unpack <$> (formatUnixTime "%Y-%m-%d %H-%M-%S" $ UnixTime (fromIntegral t) 0) 
2

unix-time 모듈 (:

secToTimestamp :: Int32 -> [Char] 

뭔가를 반환 manipulatin을위한 defacto 모듈입니다. g 시간 관련) :

import Data.Time.Clock.POSIX 
import Data.Time.Format 

secToTimestamp :: Int32 -> String 
secToTimestamp = formatTime defaultTimeLocale "%F %X" . posixSecondsToUTCTime . fromIntegral 
관련 문제