<commit_before>module Time where

import Primitives

import Data.Time
import Data.Ratio ((%))
import Numeric.Units.Dimensional.Prelude

addTime :: Time' -> UTCTime -> UTCTime
addTime x t = addUTCTime (toNominalDiffTime x) t

toNominalDiffTime :: Time' -> NominalDiffTime
toNominalDiffTime t = fromRational $ (ps % 1000000000000)
  where ps = round (t /~ pico second)

toMicroseconds :: Time' -> Int
toMicroseconds t = round (t /~ micro second)

toNearestSecond :: UTCTime -> UTCTime
toNearestSecond utc = utc { utctDayTime = rounded }
  where rounded = secondsToDiffTime seconds
        seconds = round (toRational dayTime)
        dayTime = utctDayTime utc
<commit_msg>Added function to get time to nearest second<commit_after>module Time where

import Primitives

import Data.Time
import Data.Ratio ((%))
import Control.Monad (liftM)
import Numeric.Units.Dimensional.Prelude

addTime :: Time' -> UTCTime -> UTCTime
addTime x t = addUTCTime (toNominalDiffTime x) t

toNominalDiffTime :: Time' -> NominalDiffTime
toNominalDiffTime t = fromRational $ (ps % 1000000000000)
  where ps = round (t /~ pico second)

toMicroseconds :: Time' -> Int
toMicroseconds t = round (t /~ micro second)

toNearestSecond :: UTCTime -> UTCTime
toNearestSecond utc = utc { utctDayTime = rounded }
  where rounded = secondsToDiffTime seconds
        seconds = round (toRational dayTime)
        dayTime = utctDayTime utc

getRoundedTime :: IO UTCTime
getRoundedTime = liftM toNearestSecond getCurrentTime

{'fraction_non_alphanumeric': 0.0862533692722372, 'fraction_numerical': 0.01752021563342318, 'mean_word_length': 4.380434782608695, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6654473', 'n_tokens_mistral': 518, 'n_tokens_neox': 475, 'n_words': 145}