/****************************************************************************/
/* Copyright 1992 to 1998 MBARI                                             */
/****************************************************************************/
/* Summary  : Installs hook to system date/time for dosFsDateTimeInstall    */
/* Filename : dosFsTimeHook                                                 */
/* Author   : Andrew Pearce                                                 */
/* Project  : Nav Processor for Western Flyer                               */
/* Version  : Version 1.0                                                   */
/* Created  : 11/23/98                                                      */
/* Modified : 11/23/98                                                      */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/* $Header: $
 * $Log:    $
 */
/****************************************************************************/
/* see vxWorks programmers guide version 5.3.1 page 210-211 for an          
   explanation of this brain damage. pean 11/24/98

   NOTE. This implementation is Y2K compliant.                              */
/****************************************************************************/

#include <vxWorks.h>                /* vxWorks system declarations          */
#include <dosFsLib.h>               /* vxWorks DOS file system definitons   */
#include <time.h>	            /* vxWorks time and date functions      */
#include <dosFsTime.h>              /* My function installs dos fs date/time*/

    static void
getSystemDateTime( DOS_DATE_TIME * dosDateTime)
{
  time_t timeNow;                   /* Time from real-time clock            */
  struct tm *lt;		    /* Local time in broken down form       */

  time ( &timeNow );                /* Read real-time clock                 */
  lt = localtime(&timeNow);
  
  dosDateTime->dosdt_year   = lt->tm_year + (lt->tm_year < 70 ? 2000 : 1900);  
  dosDateTime->dosdt_month  = lt->tm_mon  + 1;  
  dosDateTime->dosdt_day    = lt->tm_mday; 	
  dosDateTime->dosdt_hour   = lt->tm_hour;
  dosDateTime->dosdt_minute = lt->tm_min;
  dosDateTime->dosdt_second = lt->tm_sec;
} /* getSystemDateTime() */

    void
dosFsInstallTimeDate( void )
{
  dosFsDateTimeInstall((FUNCPTR) getSystemDateTime);
} /* dosFsTimeHookAdd() */


