On Sat, Aug 18, 2012 at 8:27 PM, Adde Nilsson <trialcodr@gmail.com> wrote:
Hi.
How do you add to or subtract from a LocalTime? 
I'm trying to subtract a second from a LocalTime value but the only API's I can find act only on the TimeOfDay part.

subSec :: LocalTime -> LocalTime
subSec (LocalTime d t) = LocalTime d $ timeToTimeOfDay ((timeOfDayToTime t) - (secondsToDiffTime 1))

I'm obviously on the wrong track as this looks way too complex for what it's trying to achieve.
Calling with '2012-08-18 00:00:00' gives '2012-08-18 -01:59:59' which isn't very helpful. How do I get to '2012-08-17 23:59:59'?

The time-lens [1] package should do what you need.

[1]: http://hackage.haskell.org/package/time-lens

Roman