Silverfrost Forums

Welcome to our forums

date and time from nanoseconds since 1601

19 Oct 2012 2:57 #10859

I have a large number of echosounder files that return the time in nanoseconds since 1601 as two 4-byte integers, LowDateTime and HighDateTime, which I hope I can convert into milliseconds or seconds since 1601.

Is there a Fortran subroutine that will return the ping_date (yyy mm dd) and the time since midnight on that day (hh mm ss)?

19 Oct 2012 4:16 #10860

Norm,

A long time ago, someone suplied me JDATE, which calculates the number of days since some nominal day. I think that it copes with a leap century every 400 years. It would be easy to check.

      integer*4 year, month, day, days, next, jdate
      external jdate
!
      month = 1
      day   = 1
!
      do year = 0,2000
         days = jdate (year, month, day)
         next = jdate (year+1, month, day)
         if (next-days /= 365 .or. year<4)  &
         write (*,*) year, days, next-days
      end do
      end

      integer*4 FUNCTION jdate (year,month,day)
!
!   Converts DAY/MONTH/YEAR to a Julian day
!
      INTEGER*4 day, month, year
!
!    'Tony T. Warnock' <u091889@lanl.gov>
!     Sent by: fortran-owner@lahey.com
!     31/10/2002 02:04 AM
!
!      jdate = 367*year
!     1      - 7*(year+(month+9)/12)/4
!     1      - 3*((year+(month-9)/7)/100+1)/4
!     1      + 275*month/9+day
!     1      - 730516
!
       jdate = 367*year                          &
             - 7*(year+(month+9)/12)/4           &
             - 3*((year+(month-9)/7)/100+1)/4    &
             + (275*month)/9 - 30                &
             + day-1
!            -    366                    !    1/1/1
!            - 584388                    ! 1600/1/1
!            - 693961                    ! 1900/1/1
!            - 723180                    ! 1980/1/1
!            - 726833                    ! 1990/1/1
!            - 728659                    ! 1995/1/1
!            - 730485                    ! 2000/1/1
!
      END FUNCTION jdate
19 Oct 2012 5:06 #10861

Thanks John

If I went that route, then I'd need the reverse calculation -- from Julian day to yy mm dd (apparently Jan 1 1601 = Julian day 2305813.5).

Can someone tell me what the initial date for SECS is in CONVDATE@? Is it 1st January 1980, as for SECONDS_SINCE_1980@?

Please login to reply.