Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Data.Time.Clock provides DiffTime and NominalDiffTime?

What is the rationale behind providing DiffTime and NominalDiffTime in Data.Time.Clock?

Currently, I don't see the need for both.

Also, I don't understand why for NominalDiffTime there is diffUTCTime, while for DiffTime there is not such a function.

I mean, it looks like DiffTime and NominalDiffTime are not really 'symmetric' to each other.

Perhaps to sum it up: What is the difference between those algebraic datatypes?

like image 815
maxschlepzig Avatar asked Nov 08 '12 22:11

maxschlepzig


1 Answers

NominalDiffTime ignores leap-seconds and you can be sure that diffUTCTime between 23:00 UTC and 01:00 UTC of next day is always 2 hours, without any seconds added.

Result of DiffTime can be changed by other factors, for example, leap-seconds. This is measured as with stopwatch: if, for some reasons, between 23:00 UTC and 01:00 UTC is not 2 hours, this type will show it.

In practice, they did not differ.

EDIT: They have different objectives.

  • NominalDiffTime is for calculating difference between the times.
  • DiffTime is for measured time (with stopwatch, for example).
like image 65
matshch Avatar answered Sep 18 '22 20:09

matshch