/****************************************************************
 * Filename  :	Time.c
 * Functions :	
 *		Time_SetValue
 * Purpose   : 	Functions for the Time class
 * Comment   : 	This class inherit from Counter
 $Revision: 1.1 $
 ***************************************************************/

#include <types.h>                      /* MBARI style guide type declarations*/
#include "dmvideo.h"                    /* data manager definitions           */
#include "dy4std.h"                     /* DY4 standard definitions           */
#include "mygraphics.h"                 /* graphics alignment definitions     */
#include "OVtypes.h"                    /* video overlay type definitions     */
#include "Time.h" 			/* definitions for Time class         */

/*---------------------------------------------------------------
 | Function  :	Time_SetValue
 | Purpose   : 	
 | Inputs    :	none
 | Outputs   :	none
 | Side FX   :	none
 | comments  :  call by upper class method Counter_SetValue
 | Author    :	sylvain.coudray MBARI-IFREMER/diti/dsi/ie
 | Modified  :  tarrant 8/8/96
 |                changed current_seconds to non-pointer
 |                removed #include <time.h>
 ---------------------------------------------------------------*/
    void
Time_SetValue(OV_Item *p_item, OV_char *value)
{
	time_t		current_seconds; /* to store seconds */
	struct	tm 	*current_date;	  /* to store date&time */
	OV_int		nb_char;	  /* string_date length */	
	OV_char		string_minutes[3];
	OV_char		string_hours[3];
	OV_char		string_seconds[3];
	OV_int		seconds;	
	OV_int		minutes;	
	OV_int		hours;	


	/* ....................... */
	/* ... Initializations ... */
	/* ....................... */

	/* get current date and time */
	time(&current_seconds); 
	current_date = localtime (&current_seconds);
	seconds = current_date->tm_sec;
	minutes = current_date->tm_min;
	hours   = current_date->tm_hour;

	/* ............. */
	/* ... Begin ... */
	/* ............. */

	/* allocate string for current value */
	nb_char = 8+1;
   	p_item->value = (char *) malloc ( nb_char);

	/* write value according to format */

	if ( minutes < 10) {
	  sprintf ( string_minutes, "0%1d", minutes);
	} else {
	  sprintf ( string_minutes, "%2d", minutes);
	}

	if ( hours < 10) {
	  sprintf ( string_hours, "0%1d", hours);
	} else {
	  sprintf ( string_hours, "%2d", hours);
	}

	if ( seconds < 10) {
	  sprintf ( string_seconds, "0%1d", seconds);
	} else {
	  sprintf ( string_seconds, "%2d", seconds);
	}

	sprintf ( p_item->value, "%s:%s:%s",
		  string_hours, string_minutes, string_seconds);

/*debug
printf ( "hours, minutes, seconds = %d %d %d\n", 
	  hours, minutes, seconds);
printf ( "p_item->value = %s \n", p_item->value);
enddebug*/

	/* ........... */
	/* ... End ... */
	/* ........... */

        return;

} /* Time_SetValue */

/*---------------------------------------------------------------
 | Function  :	Time_cccccc
 | Purpose   : 	
 | Inputs    :	none
 | Outputs   :	none
 | Side FX   :	none
 | comments  :
 | Author    :	sylvain.coudray MBARI-IFREMER/diti/dsi/ie
 ---------------------------------------------------------------*/

	void
Time_cccccc ( p_item)
OV_Item		*p_item;
{

	/* ... Local Variables */
	/* ... Initializations */
	/* ... Begin */


	/* ... End */

        return;

} /* Time_cccccc */

