Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | date_array(6) |
Datetime [y,m,d,h,m,s] |
||
character(len=*), | intent(in) | :: | in_format_str |
Format string |
||
character(len=*), | intent(out) | :: | out_a_str |
Date string |
subroutine date_to_datestr_new(date_array, in_format_str, out_a_str) integer, intent(in) :: date_array(6) !! Datetime [y,m,d,h,m,s] character(*), intent(in) :: in_format_str !! Format string character(*), intent(out) :: out_a_str !! Date string ! Local variables integer :: pos ! Extract elements of the date string pos = index(in_format_str, 'yyyy') if (pos .gt. 0) then write(out_a_str(pos:pos+3),'(i4)') date_array(1) end if pos = index(in_format_str, 'mm') if (pos .gt. 0) then if (date_array(2) .gt. 9) then write(out_a_str(pos:pos+1),'(i2)') date_array(2) else write(out_a_str(pos:pos+1),'(a1,i1)') '0', date_array(2) end if end if pos = index(in_format_str, 'dd') if (pos.gt.0) then if (date_array(3) .gt. 9) then write(out_a_str(pos:pos+1),'(i2)') date_array(3) else write(out_a_str(pos:pos+1),'(a1,i1)') '0', date_array(3) end if end if pos = index(in_format_str, 'HH') if (pos .gt. 0) then if (date_array(4) .gt. 9) then write(out_a_str(pos:pos+1),'(i2)') date_array(4) else write(out_a_str(pos:pos+1),'(a1,i1)') '0', date_array(4) end if end if pos = index(in_format_str,'MM') if (pos .gt. 0) then if (date_array(5) .gt. 9) then write(out_a_str(pos:pos+1),'(i2)') date_array(5) else write(out_a_str(pos:pos+1),'(a1,i1)') '0', date_array(5) end if end if pos = index(in_format_str,'SS') if (pos .gt. 0) then if (date_array(6) .gt. 9) then write(out_a_str(pos:pos+1),'(i2)') date_array(6) else write(out_a_str(pos:pos+1),'(a1,i1)') '0', date_array(6) end if end if end subroutine date_to_datestr_new