source: rtems/cpukit/score/src/coretodtoseconds.c @ 4e97166

4.104.114.84.95
Last change on this file since 4e97166 was a8eed23, checked in by Ralf Corsepius <ralf.corsepius@…>, on 01/27/05 at 05:57:05

Include config.h.

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/*
2 *  Time of Day (TOD) Handler
3 *
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/system.h>
20#include <rtems/score/object.h>
21#include <rtems/score/thread.h>
22#include <rtems/score/tod.h>
23#include <rtems/score/watchdog.h>
24
25/*PAGE
26 *
27 *  _TOD_To_seconds
28 *
29 *  This routine returns the seconds from the epoch until the
30 *  current date and time.
31 *
32 *  Input parameters:
33 *    the_tod - pointer to the time and date structure
34 *
35 *  Output parameters:
36 *    returns    - seconds since epoch until the_tod
37 */
38
39uint32_t   _TOD_To_seconds(
40  TOD_Control *the_tod
41)
42{
43  uint32_t   time;
44  uint32_t   year_mod_4;
45
46  time = the_tod->day - 1;
47  year_mod_4 = the_tod->year & 3;
48
49  if ( year_mod_4 == 0 )
50    time += _TOD_Days_to_date[ 1 ][ the_tod->month ];
51  else
52    time += _TOD_Days_to_date[ 0 ][ the_tod->month ];
53
54  time += ( (the_tod->year - TOD_BASE_YEAR) / 4 ) *
55            ( (TOD_DAYS_PER_YEAR * 4) + 1);
56
57  time += _TOD_Days_since_last_leap_year[ year_mod_4 ];
58
59  time *= TOD_SECONDS_PER_DAY;
60
61  time += ((the_tod->hour * TOD_MINUTES_PER_HOUR) + the_tod->minute)
62             * TOD_SECONDS_PER_MINUTE;
63
64  time += the_tod->second;
65
66  return( time );
67}
Note: See TracBrowser for help on using the repository browser.