@@ -572,22 +572,22 @@ end function date2string
572
572
character (len= LEN_TIME_STRING_LONG) function date2longstring(date)
573
573
574
574
type (time_t), intent (in ) :: date
575
+ type (time_t) :: tmp_date
575
576
real (dp) :: second_fraction
576
577
577
578
! Handle the leading zero issue for floating point numbers (only for the seconds)
578
- second_fraction = nint ((date% second- int (date% second))* 1E6 )* 1E-6
579
- if (second_fraction > 0.999999d0 ) then
580
- ! Round to
581
- second_fraction = 0.0d0
582
- ! Create an intermediate adjusted date with seconds increased by 1
583
- write (date2longstring,' (i4,2("-",i2.2),"T",2(i2.2,":"),(i2.2,f0.6),"Z")' ) &
584
- date% year, date% month, date% day, date% hour, &
585
- date% minute, int (date% second) + 1 , second_fraction
586
- else
587
- write (date2longstring,' (i4,2("-",i2.2),"T",2(i2.2,":"),(i2.2,f0.6),"Z")' ) &
588
- date% year, date% month, date% day, date% hour, &
589
- date% minute, int (date% second), second_fraction
579
+ second_fraction = anint ((date% second- int (date% second))* 1.0d6 )/ 1.0d6
580
+ tmp_date% mjd = date% mjd
581
+ call mjd2gd(tmp_date)
582
+ if (second_fraction > 0.999999d0 ) then
583
+ ! Handle rounding to the next second using mjd2gd subroutine
584
+ second_fraction = 0.0d0
585
+ tmp_date% mjd = date% mjd + 1E-6 / sec_per_day
586
+ call mjd2gd(tmp_date)
590
587
end if
588
+ write (date2longstring,' (i4,2("-",i2.2),"T",2(i2.2,":"),i2.2,f0.6),"Z")' ) &
589
+ tmp_date% year, tmp_date% month, tmp_date% day, tmp_date% hour, &
590
+ tmp_date% minute, int (tmp_date% second), second_fraction
591
591
592
592
return
593
593
0 commit comments