replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - date and time from nanoseconds since 1601
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

date and time from nanoseconds since 1601

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
Norm.Campbell



Joined: 31 Aug 2007
Posts: 66

PostPosted: Fri Oct 19, 2012 3:57 am    Post subject: date and time from nanoseconds since 1601 Reply with quote

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)?
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2615
Location: Sydney

PostPosted: Fri Oct 19, 2012 5:16 am    Post subject: Reply with quote

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.
Code:
      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
Back to top
View user's profile Send private message
Norm.Campbell



Joined: 31 Aug 2007
Posts: 66

PostPosted: Fri Oct 19, 2012 6:06 am    Post subject: Reply with quote

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@?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group