Fix time parsing and clean up
This commit is contained in:
parent
ce13ce11fc
commit
5ecf9864d3
2 changed files with 14 additions and 12 deletions
|
|
@ -51,14 +51,14 @@ newOpenChanSTM :: STM (CloseableChan a)
|
||||||
newOpenChanSTM = do
|
newOpenChanSTM = do
|
||||||
cClosed <- newTVar False
|
cClosed <- newTVar False
|
||||||
cChan <- newTChan
|
cChan <- newTChan
|
||||||
return $ CloseableChan{..}
|
return CloseableChan{..}
|
||||||
|
|
||||||
-- | See 'newClosedChan'.
|
-- | See 'newClosedChan'.
|
||||||
newClosedChanSTM :: STM (CloseableChan a)
|
newClosedChanSTM :: STM (CloseableChan a)
|
||||||
newClosedChanSTM = do
|
newClosedChanSTM = do
|
||||||
cClosed <- newTVar True
|
cClosed <- newTVar True
|
||||||
cChan <- newTChan
|
cChan <- newTChan
|
||||||
return $ CloseableChan{..}
|
return CloseableChan{..}
|
||||||
|
|
||||||
-- | See 'writeChan'.
|
-- | See 'writeChan'.
|
||||||
writeChanSTM :: CloseableChan a -> a -> STM (Maybe ())
|
writeChanSTM :: CloseableChan a -> a -> STM (Maybe ())
|
||||||
|
|
@ -84,14 +84,12 @@ readChanSTM CloseableChan{..} = do
|
||||||
|
|
||||||
-- | See 'closeChan'.
|
-- | See 'closeChan'.
|
||||||
closeChanSTM :: CloseableChan a -> STM ()
|
closeChanSTM :: CloseableChan a -> STM ()
|
||||||
closeChanSTM CloseableChan{..} = do
|
closeChanSTM CloseableChan{..} = writeTVar cClosed True
|
||||||
writeTVar cClosed True
|
|
||||||
--writeTChan cChan End
|
--writeTChan cChan End
|
||||||
|
|
||||||
-- | See 'openChan'.
|
-- | See 'openChan'.
|
||||||
openChanSTM :: CloseableChan a -> STM ()
|
openChanSTM :: CloseableChan a -> STM ()
|
||||||
openChanSTM CloseableChan{..} = do
|
openChanSTM CloseableChan{..} = writeTVar cClosed False
|
||||||
writeTVar cClosed False
|
|
||||||
|
|
||||||
-- | See 'emptyChan'.
|
-- | See 'emptyChan'.
|
||||||
emptyChanSTM :: CloseableChan a -> STM [a]
|
emptyChanSTM :: CloseableChan a -> STM [a]
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import Data.Aeson
|
||||||
import Data.Function
|
import Data.Function
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import Data.Time
|
import Data.Time
|
||||||
|
import Data.Time.Clock.POSIX
|
||||||
|
|
||||||
-- | Represents <http://api.euphoria.io/#snowflake>.
|
-- | Represents <http://api.euphoria.io/#snowflake>.
|
||||||
--
|
--
|
||||||
|
|
@ -101,13 +102,16 @@ instance FromJSON Message where
|
||||||
parseJSON = withObject "Message" $ \o -> do
|
parseJSON = withObject "Message" $ \o -> do
|
||||||
msgID <- o .: "id"
|
msgID <- o .: "id"
|
||||||
msgParent <- o .:? "parent"
|
msgParent <- o .:? "parent"
|
||||||
msgTime <- o .: "time"
|
|
||||||
msgSender <- o .: "sender"
|
msgSender <- o .: "sender"
|
||||||
msgContent <- o .: "content"
|
msgContent <- o .: "content"
|
||||||
msgEdited <- o .:? "edited"
|
time <- o .: "time"
|
||||||
msgDeleted <- o .:? "deleted"
|
edited <- o .:? "edited"
|
||||||
|
deleted <- o .:? "deleted"
|
||||||
msgTruncated <- o .:? "truncated" .!= False
|
msgTruncated <- o .:? "truncated" .!= False
|
||||||
return $ Message{..}
|
let msgTime = posixSecondsToUTCTime time
|
||||||
|
msgEdited = posixSecondsToUTCTime <$> edited
|
||||||
|
msgDeleted = posixSecondsToUTCTime <$> deleted
|
||||||
|
return Message{..}
|
||||||
|
|
||||||
-- | Represents <http://api.euphoria.io/#sessionview>.
|
-- | Represents <http://api.euphoria.io/#sessionview>.
|
||||||
--
|
--
|
||||||
|
|
@ -135,4 +139,4 @@ instance FromJSON SessionView where
|
||||||
sessSessionID <- o .: "session_id"
|
sessSessionID <- o .: "session_id"
|
||||||
isStaff <- o .:? "is_staff" .!= False
|
isStaff <- o .:? "is_staff" .!= False
|
||||||
isManager <- o .:? "is_manager" .!= False
|
isManager <- o .:? "is_manager" .!= False
|
||||||
return $ SessionView{..}
|
return SessionView{..}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue