add a time interval to a timestamp

Loris Fichera <>
Tue Mar 15 11:54:31 CET 2011

Hello everybody,

Say I want to write a function that takes as input a timestamp (in the
form {{y,m,d}, {h,m,s}} ) and returns another timestamp, obtained by
adding a certain amount of {hours, minutes, seconds} to the input.

It wouldn't be difficult but, since I'm dealing with tuples, I wouldn't
have any guarantee on the validity of the obtained timestamp, e.g. I
could have obtained something like {{2011,02,30},{...}}. In such cases,
the calendar:valid_date/1 and calendar:last_day_of_the_month/2 would be

I was just wondering if there already exists a function that does such a
work. :)

Thanks in advance.
[ "let me take you down, 'cos i'm going to Strawberry Fields."   ]
[ Loris Fichera a.k.a. kid_a  |  HOME  ]
[ JABBER loris[dot]fichera[at]gmail[dot]com |GPG key ID 8B343E44 ]

More information about the erlang-questions mailing list