COSIMA / datetime-fortran

Date and time manipulation for modern Fortran
https://wavebitscientific.github.io/datetime-fortran/
Other
0 stars 0 forks source link

Hour comparison in num2date is incorrect #4

Open penguian opened 4 years ago

penguian commented 4 years ago

In num2date in mod_datetime.f90, line 1245 has:

  if(num2date % hour == 60)then

Surely that comparison should be to 24, not 60?

russfiedler commented 4 years ago

Definitely incorrect code.

aekiss commented 4 years ago

Good catch - this is in the master at wavebitscientific - maybe raise the issue there? https://github.com/wavebitscientific/datetime-fortran/blob/master/src/lib/mod_datetime.f90#L1238

penguian commented 4 years ago

Done. https://github.com/wavebitscientific/datetime-fortran/issues/64

aekiss commented 4 years ago

This mix of integer and real arithmetic makes me nervous too. But I think I'm right in saying 1e3 has an exact representation as a float, so I guess that helps... https://github.com/wavebitscientific/datetime-fortran/blob/master/src/lib/mod_datetime.f90#L1215-L1228