<p>I want to calculate the length of time between time ta and time tb.<br>Time ta is a String looking like "N:NNAM" or "N:NNPM."<br>I need tb to be 9:30AM on the current date.</p>
<p>I think the flow should be<br>1) parse ta to utcTimeA :: UTCTime<br>2) get current date and form tb to utcTimeB :: UTCTime<br>3) call "diffUTCTime utcTimeA utcTimeB"</p>
<p>So my program looks like as follows in a "do" expression:</p>
<p> let utcTimeA = fromJust (parseTime defaultTimeLocale "%R%P" ta :: Maybe UTCTime)<br> currentTime <- getCurrentTime<br> let day = utctDay currentTime<br> let utcTimeB = UTCTime day "09:30:00.0000000 UTC"<br>
let timeElapsed = diffUTCTime utcTimeA utcTimeB</p>
<p>There are two difficulties I could not get around:<br>1) It seems that parseTime returns "Nothing". Why?<br>2) I knew "09:30:00.0000000 UTC" in the statement of "let utcTimeB ..." is incorrect, because it is a String instead of expected DiffTime type. After consulting Data.Time module (it just say "Data DiffTime"), I still cannot figure out how to get utcTimeB.</p>
<p>Can someone help me?</p>
<p>Thanks,</p>
<p>Hong</p>