source: rtems/cpukit/score/src/coretodtoseconds.c @ 59d1127

4.104.114.84.95
Last change on this file since 59d1127 was 93b4e6ef, checked in by Joel Sherrill <joel.sherrill@…>, on 11/02/99 at 21:05:17

Split Heap and Time of Day Handlers.

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