My goal is to make fortran return the difference between two times that were passed in as character strings, very simular to VBA's TimeDiff. I've been going through the handling of date and time in fortran for quite a while now, but couldn't find what I need in this perticular case. The first problem in fortran is how to turn a string into a further computable time variable. time_and_dates ctime for example converts the time into a character string, but whats needed in my case is the exact opposite.
Since fortran easily calculates things like a spot watch for the time needed for a programm to finish and even dislays the time from the system itself, it obviously is able to calculate these kind of stuff if my thoughts are right so far.
But how to pass my String "YYYYMMDD HHMMSS" into the time format, how to calculate with it and how to phrase the output?
Here an example of where this should lead:
date1 = as.date("20130512 091519") !Stringinput
date2 = as.date("20131116 120418")
result = time.difference(date1,date2,outputunit="seconds")
print*, 'time diff in sec: ', result !returns something like 4646345 as Integer
Due to fortrans ability to do such calculations in other context (stop watch etc) I would really appreciate a solution that does not involve any extern extensions or adventurous manual coding (365 ...leap year... /400..and so on).
Is there a way to use the intern possibilies of fortran and the system (win64) for my purpose?
If not, on which way passes the system its time information into fortran and can this possibly be imitated (so the source isn't "system" but "character string" instead)?
EDIT: Thanks for the input so far, but as mentioned above I would preferably use fortrans intern abilities (as it happens in stop watch) for the job instead of extensions or manual calculations. I find it hard to belief that date&time can only be converted to character but not the other way round... but thank you anyway.