Time Struct Reference


Public Methods

void Time_decode (struct Time *ptr_time, time_t time)
time_t Time_encode (struct Time *ptr_time)
bool Time_set_RTC (struct Time *ptr_time)
bool Time_get_RTC (struct Time *ptr_time)
int Time_get_weekday (struct Time *ptr_time)
int Time_clear_alarm_flag (void)
bool Time_enable_alarm_int (bool enable)
clock_t clock (void)
time_t time (void)
time_t get_trusted_time (void)

Public Attributes

char year
char month
char day
char hour
char minute
char second
char hundreds


Detailed Description

A time manipulation structure.

See also:
Time-related


Member Function Documentation

int Time_clear_alarm_flag ( void )
 

Resets the alarm flag.

Returns:
1 if alarm flag was set, 0 if not set, -1 if the flag could not be read
       #include <cybiko.h>
       ...
       // It's the same as using the Time_enable_alarm_int( FALSE ) function.
       // Turns off the alarm.
       Time_clear_alarm_flag();
       ...
       // Turns on the alarm.
       Time_enable_alarm_int( TRUE );
See also:
Time_enable_alarm_int.

void Time_decode ( struct Time * ptr_time,
time_t time )
 

Decodes 'time' and fill fields.

Parameters:
ptr_time   A pointer to a Time object
time   The time_t format.
Returns:
None
       #include <cybiko.h>
       ...
       struct Time time;
       ...
       Time_decode( &time, last_key_time() );
       TRACE("Last key was pressed at hour: %d, minutes: %d, seconds: %d",
             time.hour, 
             time.minute, 
             time.second );
       ...
See also:
Time_encode.

bool Time_enable_alarm_int ( bool enable )
 

Sets or resets the alarm flag.

Parameters:
enable   If TRUE, the alarm flag will be set, else will be reset
Returns:
The previous state of the alarm flag
       #include <cybiko.h>
       ...
       // It's the same as using the Time_enable_alarm_int( FALSE ) function.
       // Turns off the alarm.
       Time_clear_alarm_flag();
       ...
       // Turns on the alarm.
       Time_enable_alarm_int( TRUE );
See also:
Time_clear_alarm_flag.

time_t Time_encode ( struct Time * ptr_time )
 

Packs fields into the time_t type.

Parameters:
ptr_time   A pointer to a Time object
Returns:
Packed field in the time_t type
       #include <cybiko.h>
       ...
       time_t packed_time;
       struct Time time;
       ...
       // 99 is 1999, 100 is 2000 and etc.
       time.year  = 100;
       time.month = 02;
       time.day = 07;
       time.hour = 22;
       time.minute = 15;
       time.second = 15;
       time.hundreds = 10;
       ...
       packed_time = Time_encode( &time );
       ...
See also:
Time_decode , time_t.

bool Time_get_RTC ( struct Time * ptr_time )
 

Sets the fields according to the values read from the Real Time Clock (RTC).

Parameters:
ptr_time   A pointer to a Time object
Returns:
TRUE if the field was set successfully
       #include <cybiko.h>
       ...
       struct Time time;
       Time_get_RTC( &time );
       time.hour++;
       time.hour %= 24;
       // We have changed the clock one hour ahead.
       Time_set_RTC( &time );
       ...

int Time_get_weekday ( struct Time * ptr_time )
 

Calculates the weekday for the current date (Sunday is 0, Saturday is 6).

Parameters:
ptr_time   A pointer to a Time object
Returns:
The weekday number
       #include <cybiko.h>
       ...
       int week_day;
       struct Time time;
       ...
       Time_get_RTC( &time );
       ...
       week_day = Time_get_weekday( &time );
       ...

bool Time_set_RTC ( struct Time * ptr_time )
 

Sets the Real Time Clock (RTC) according to its fields.

Parameters:
ptr_time   A pointer to a Time object
Returns:
TRUE if the time was set successfully
       #include <cybiko.h>
       ...
       struct Time time;
       Time_get_RTC( &time );
       time.hour++;
       time.hour %= 24;
       //  We have changed the clock one hour ahead. 
       Time_set_RTC( &time );


Member Data Documentation

char day
 

Day of month, 1..31.

char hour
 

Hour, 0..23.

char hundreds
 

Hundredths of a second, 0..99.

char minute
 

Minute, 0..59.

char month
 

Month, 1..12.

char second
 

Second, 0..59.

char year
 

Year - 1900, 99 means 1999.