mbgtools-lx  4.2.8
mbgtime.h File Reference
#include <gpsdefs.h>
#include <time.h>

Go to the source code of this file.

Data Structures

struct  TIMEOUT
 

Macros

#define _ext   extern
 
#define GPS_SEC_BIAS   315964800UL
 GPS epoch bias from ordinary time_t epoch. More...
 
#define NTP_SEC_BIAS   2208988800UL
 NTP epoch bias from ordinary time_t epoch. More...
 
#define NTP_FRAC_PER_SEC   (uint64_t) 4294967296.0
 
#define MJD_AT_GPS_EPOCH   44244UL
 
#define MJD_AT_UNIX_EPOCH   40587UL
 
#define MJD_AT_NTP_EPOCH   40587UL
 
#define MASK_CLOCK_T   0x7FFF
 
#define DAYS_PER_WEEK   7
 
#define SECS_PER_MIN   60
 
#define MINS_PER_HOUR   60
 
#define HOURS_PER_DAY   24
 
#define DAYS_PER_WEEK   7
 
#define MINS_PER_DAY   ( MINS_PER_HOUR * HOURS_PER_DAY )
 
#define SECS_PER_HOUR   3600
 
#define SECS_PER_DAY   86400L
 
#define SECS_PER_WEEK   604800L
 
#define SEC100S_PER_SEC   100L
 
#define SEC100S_PER_MIN   ( SEC100S_PER_SEC * SECS_PER_MIN )
 
#define SEC100S_PER_HOUR   ( SEC100S_PER_SEC * SECS_PER_HOUR )
 
#define SEC100S_PER_DAY   ( SEC100S_PER_SEC * SECS_PER_DAY )
 
#define MSEC_PER_SEC   1000L
 
#define MSEC_PER_MIN   ( MSEC_PER_SEC * SECS_PER_MIN )
 
#define MSEC_PER_HOUR   ( MSEC_PER_SEC * SECS_PER_HOUR )
 
#define MSEC_PER_DAY   ( MSEC_PER_SEC * SECS_PER_DAY )
 
#define USEC_PER_SEC   1000000L
 
#define NSEC_PER_SEC   1000000000L
 
#define HNS_PER_SEC   10000000L
 
#define HNS_PER_MS   10000L
 
#define HNS_PER_MIN   ( HNS_PER_SEC * SECS_PER_MIN )
 
#define MSEC_TO_NSEC_MULTIPLIER   ( NSEC_PER_SEC / MSEC_PER_SEC )
 
#define MSEC_TO_USEC_MULTIPLIER   ( USEC_PER_SEC / MSEC_PER_SEC )
 
#define DAYS_OF_MONTH_TABLE_INIT
 An initializer for a DAYS_OF_MONTH_TABLE. More...
 
#define _n_days(_s)   n_days( (_s)->mday, (_s)->month, (_s)->year )
 
#define _is_leap_year(_y)   ( ( ( ( (_y) % 4 ) == 0 ) && ( ( (_y) % 100 ) != 0 ) ) || ( ( (_y) % 400 ) == 0 ) )
 
#define _get_days_of_month(_y, _m)   days_of_month[ _is_leap_year( _y ) ][_m]
 
#define MBG_FRAC32_CONVERSION_TYPE   int64_t
 Data type used for intermediate results on 32 bit multiplications. More...
 
#define MBG_FRAC32_UNITS_PER_SEC   ( (MBG_FRAC32_CONVERSION_TYPE) 4294967296.0 )
 Constant used to convert e.g. PCPS_TIME_STAMP::frac values. More...
 
#define bin_frac_32_to_msec(_bin)   bin_frac_32_to_dec_frac( (_bin), 1000L )
 
#define bin_frac_32_to_usec(_bin)   bin_frac_32_to_dec_frac( (_bin), 1000000L )
 
#define bin_frac_32_to_nsec(_bin)   bin_frac_32_to_dec_frac( (_bin), 1000000000L )
 
#define bin_frac_16_to_msec(_bin)   bin_frac_16_to_dec_frac( (_bin), 1000L )
 
#define bin_frac_16_to_usec(_bin)   bin_frac_16_to_dec_frac( (_bin), 1000000L )
 
#define bin_frac_16_to_nsec(_bin)   bin_frac_16_to_dec_frac( (_bin), 1000000000L )
 
#define msec_to_bin_frac_32(_msec)   dec_frac_to_bin_frac_32( (_msec), 1000L )
 
#define usec_to_bin_frac_32(_usec)   dec_frac_to_bin_frac_32( (_usec), 1000000L )
 
#define nsec_to_bin_frac_32(_nsec)   dec_frac_to_bin_frac_32( (_nsec), 1000000000L )
 
#define msec_to_bin_frac_16(_msec)   dec_frac_to_bin_frac_16( (_msec), 1000L )
 
#define usec_to_bin_frac_16(_usec)   dec_frac_to_bin_frac_16( (_usec), 1000000L )
 
#define nsec_to_bin_frac_16(_nsec)   dec_frac_to_bin_frac_16( (_nsec), 1000000000L )
 

Typedefs

typedef char DAYS_OF_MONTH_TABLE[2][12]
 A table with the days of month. More...
 

Functions

static __mbg_inline uint32_t bin_frac_16_to_dec_frac (uint16_t bin, uint32_t scale)
 Convert a 16 bit binary fraction to a scaled decimal. More...
 
static __mbg_inline uint32_t bin_frac_32_to_dec_frac (uint32_t bin, uint32_t scale)
 Convert a 32 bit binary fraction to a scaled decimal. More...
 
static __mbg_inline uint16_t dec_frac_to_bin_frac_16 (uint32_t dec, uint32_t scale)
 
static __mbg_inline uint32_t dec_frac_to_bin_frac_32 (uint32_t dec, uint32_t scale)
 
static __mbg_inline uint32_t frac_sec_from_bin (uint32_t b, uint32_t scale)
 Convert a binary fraction to a scaled decimal. More...
 
static __mbg_inline double dfrac_sec_from_bin (uint32_t b)
 Convert a binary fraction to "double" fractions. More...
 
void set_timeout (TIMEOUT *t, clock_t clk, clock_t interval)
 Set a timeout object to specified interval. More...
 
void stretch_timeout (TIMEOUT *t, clock_t interval)
 Stretch a timeout specified in given timeout object. More...
 
bit check_timeout (TIMEOUT *t, clock_t clk)
 Check if a timeout object has expired. More...
 
int err_tm (const TM_GPS *tm)
 Check if a TM_GPS structure contains a valid date and time. More...
 
TM_GPSclear_time (TM_GPS *tm)
 Set the time in a TM_GPS structure to 00:00:00.000. More...
 
TM_GPSwsec_to_tm (long wsec, TM_GPS *tm)
 Convert second-of-week to day-of-week and time-of-day. More...
 
long tm_to_wsec (const TM_GPS *tm)
 Compute second-of-week from day-of-week and time-of-day. More...
 
int is_leap_year (int y)
 Check if a specific year is a leap year. More...
 
int day_of_year (int day, int month, int year)
 Compute the day-of-year from a given date. More...
 
void date_of_year (int year, int day_num, TM_GPS *tm)
 Compute a date from a given year and day-of-year. More...
 
int day_of_week (int day, int month, int year)
 Compute day-of-week from a given date. More...
 
int days_to_years (long *day_num, int year)
 Update a year number by a number of days, accounting for leap years. More...
 
long n_days (ushort mday, ushort month, ushort year)
 Compute number of days after Jan 1, 0000 for a given date. More...
 
int sprint_time (char *s, const TM_GPS *tm)
 Print time with hours, minutes, seconds to a string. More...
 
int sprint_short_time (char *s, const TM_GPS *tm)
 Print time with hours, minutes to a string. More...
 
int sprint_date (char *s, const TM_GPS *tm)
 Print date to a string. More...
 
int sprint_day_date (char *s, const TM_GPS *tm)
 Print day-of-week and date to a string. More...
 
int sprint_tm (char *s, const TM_GPS *tm)
 Print day-of-week, date and time to a string. More...
 
void sscan_time (const char *s, TM_GPS *tm)
 Extract a time from a string. More...
 
void sscan_date (char *s, TM_GPS *tm)
 Extract a date from a string. More...
 

Variables

TM_GPS dhms
 
TM_GPS datum
 
const char * short_time_fmt
 
const char * time_fmt
 
const char * long_time_fmt
 
const char * date_fmt
 
const char * day_date_fmt
 
const char * day_name_eng []
 
const char * day_name_ger []
 
const TM_GPS init_tm
 
DAYS_OF_MONTH_TABLE days_of_month
 

Macro Definition Documentation

◆ _ext

#define _ext   extern

Definition at line 113 of file mbgtime.h.

◆ _get_days_of_month

#define _get_days_of_month (   _y,
  _m 
)    days_of_month[ _is_leap_year( _y ) ][_m]

Definition at line 375 of file mbgtime.h.

◆ _is_leap_year

#define _is_leap_year (   _y)    ( ( ( ( (_y) % 4 ) == 0 ) && ( ( (_y) % 100 ) != 0 ) ) || ( ( (_y) % 400 ) == 0 ) )

Definition at line 371 of file mbgtime.h.

◆ _n_days

#define _n_days (   _s)    n_days( (_s)->mday, (_s)->month, (_s)->year )

Definition at line 367 of file mbgtime.h.

◆ bin_frac_16_to_msec

#define bin_frac_16_to_msec (   _bin)    bin_frac_16_to_dec_frac( (_bin), 1000L )

Definition at line 479 of file mbgtime.h.

◆ bin_frac_16_to_nsec

#define bin_frac_16_to_nsec (   _bin)    bin_frac_16_to_dec_frac( (_bin), 1000000000L )

Definition at line 481 of file mbgtime.h.

◆ bin_frac_16_to_usec

#define bin_frac_16_to_usec (   _bin)    bin_frac_16_to_dec_frac( (_bin), 1000000L )

Definition at line 480 of file mbgtime.h.

◆ bin_frac_32_to_msec

#define bin_frac_32_to_msec (   _bin)    bin_frac_32_to_dec_frac( (_bin), 1000L )

Definition at line 476 of file mbgtime.h.

Referenced by snprint_ntp_tstamp_to_iso_ms().

◆ bin_frac_32_to_nsec

#define bin_frac_32_to_nsec (   _bin)    bin_frac_32_to_dec_frac( (_bin), 1000000000L )

Definition at line 478 of file mbgtime.h.

Referenced by snprint_ntp_tstamp_to_iso_ns().

◆ bin_frac_32_to_usec

#define bin_frac_32_to_usec (   _bin)    bin_frac_32_to_dec_frac( (_bin), 1000000L )

Definition at line 477 of file mbgtime.h.

Referenced by snprint_ntp_tstamp_to_iso_us().

◆ DAYS_OF_MONTH_TABLE_INIT

#define DAYS_OF_MONTH_TABLE_INIT
Value:
{ \
{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, \
{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } \
}

An initializer for a DAYS_OF_MONTH_TABLE.

Definition at line 297 of file mbgtime.h.

◆ DAYS_PER_WEEK [1/2]

#define DAYS_PER_WEEK   7

Definition at line 238 of file mbgtime.h.

◆ DAYS_PER_WEEK [2/2]

#define DAYS_PER_WEEK   7

Definition at line 238 of file mbgtime.h.

◆ GPS_SEC_BIAS

#define GPS_SEC_BIAS   315964800UL

GPS epoch bias from ordinary time_t epoch.

The Unix time_t epoch is usually 1970-01-01 00:00 whereas the GPS epoch is 1980-01-06 00:00, so the difference is 10 years, plus 2 days due to leap years (1972 and 1976), plus the difference of the day-of-month (6 - 1), so:

time_t t = ( gps_week * SECS_PER_WEEK ) + sec_of_week + GPS_SEC_BIAS

Definition at line 130 of file mbgtime.h.

Referenced by show_utc_info().

◆ HNS_PER_MIN

#define HNS_PER_MIN   ( HNS_PER_SEC * SECS_PER_MIN )

Definition at line 276 of file mbgtime.h.

◆ HNS_PER_MS

#define HNS_PER_MS   10000L

Definition at line 272 of file mbgtime.h.

Referenced by mbg_delta_sys_time_ms().

◆ HNS_PER_SEC

#define HNS_PER_SEC   10000000L

Definition at line 268 of file mbgtime.h.

Referenced by mbg_get_sys_uptime(), mbg_sleep_sec(), and snprint_gmtime_error().

◆ HOURS_PER_DAY

#define HOURS_PER_DAY   24

Definition at line 237 of file mbgtime.h.

◆ MASK_CLOCK_T

#define MASK_CLOCK_T   0x7FFF

Definition at line 218 of file mbgtime.h.

◆ MBG_FRAC32_CONVERSION_TYPE

#define MBG_FRAC32_CONVERSION_TYPE   int64_t

Data type used for intermediate results on 32 bit multiplications.

We need 64 bits for intermediate integer results to avoid a range overflow from 32 x 32 bit multiplications. On systems which don't support 64 bit types we use the "double" type as a workaround.

Definition at line 392 of file mbgtime.h.

Referenced by bin_frac_16_to_dec_frac(), bin_frac_32_to_dec_frac(), dec_frac_to_bin_frac_16(), and dec_frac_to_bin_frac_32().

◆ MBG_FRAC32_UNITS_PER_SEC

◆ MINS_PER_DAY

#define MINS_PER_DAY   ( MINS_PER_HOUR * HOURS_PER_DAY )

Definition at line 240 of file mbgtime.h.

◆ MINS_PER_HOUR

#define MINS_PER_HOUR   60

Definition at line 236 of file mbgtime.h.

Referenced by set_new_ref_offs(), show_signal(), snprint_hours_mins(), and snprint_utc_offs().

◆ MJD_AT_GPS_EPOCH

#define MJD_AT_GPS_EPOCH   44244UL

Definition at line 154 of file mbgtime.h.

◆ MJD_AT_NTP_EPOCH

#define MJD_AT_NTP_EPOCH   40587UL

Definition at line 156 of file mbgtime.h.

◆ MJD_AT_UNIX_EPOCH

#define MJD_AT_UNIX_EPOCH   40587UL

Definition at line 155 of file mbgtime.h.

◆ MSEC_PER_DAY

#define MSEC_PER_DAY   ( MSEC_PER_SEC * SECS_PER_DAY )

Definition at line 257 of file mbgtime.h.

◆ MSEC_PER_HOUR

#define MSEC_PER_HOUR   ( MSEC_PER_SEC * SECS_PER_HOUR )

Definition at line 256 of file mbgtime.h.

◆ MSEC_PER_MIN

#define MSEC_PER_MIN   ( MSEC_PER_SEC * SECS_PER_MIN )

Definition at line 255 of file mbgtime.h.

◆ MSEC_PER_SEC

#define MSEC_PER_SEC   1000L

Definition at line 252 of file mbgtime.h.

Referenced by snprint_time_t_to_iso_ms().

◆ msec_to_bin_frac_16

#define msec_to_bin_frac_16 (   _msec)    dec_frac_to_bin_frac_16( (_msec), 1000L )

Definition at line 487 of file mbgtime.h.

◆ msec_to_bin_frac_32

#define msec_to_bin_frac_32 (   _msec)    dec_frac_to_bin_frac_32( (_msec), 1000L )

Definition at line 484 of file mbgtime.h.

◆ MSEC_TO_NSEC_MULTIPLIER

#define MSEC_TO_NSEC_MULTIPLIER   ( NSEC_PER_SEC / MSEC_PER_SEC )

Definition at line 279 of file mbgtime.h.

◆ MSEC_TO_USEC_MULTIPLIER

#define MSEC_TO_USEC_MULTIPLIER   ( USEC_PER_SEC / MSEC_PER_SEC )

Definition at line 280 of file mbgtime.h.

◆ NSEC_PER_SEC

◆ nsec_to_bin_frac_16

#define nsec_to_bin_frac_16 (   _nsec)    dec_frac_to_bin_frac_16( (_nsec), 1000000000L )

Definition at line 489 of file mbgtime.h.

◆ nsec_to_bin_frac_32

#define nsec_to_bin_frac_32 (   _nsec)    dec_frac_to_bin_frac_32( (_nsec), 1000000000L )

Definition at line 486 of file mbgtime.h.

◆ NTP_FRAC_PER_SEC

#define NTP_FRAC_PER_SEC   (uint64_t) 4294967296.0

Definition at line 145 of file mbgtime.h.

Referenced by nsec_to_ntp_frac(), ntp_frac_to_nsec(), and ntp_tstamp_to_double().

◆ NTP_SEC_BIAS

#define NTP_SEC_BIAS   2208988800UL

NTP epoch bias from ordinary time_t epoch.

The Unix time_t epoch is usually 1970-01-01 00:00 whereas the NTP epoch is 1900-01-01 00:00, so the difference is a constant number of seconds:

time_t t = ntp_time - NTP_SEC_BIAS

Definition at line 142 of file mbgtime.h.

Referenced by ntp_tstamp_to_nanotime_64(), ntp_tstamp_to_timespec(), snprint_ntp_tstamp_to_iso_ms(), snprint_ntp_tstamp_to_iso_ns(), snprint_ntp_tstamp_to_iso_us(), and timespec_to_ntp_tstamp().

◆ SEC100S_PER_DAY

#define SEC100S_PER_DAY   ( SEC100S_PER_SEC * SECS_PER_DAY )

Definition at line 249 of file mbgtime.h.

◆ SEC100S_PER_HOUR

#define SEC100S_PER_HOUR   ( SEC100S_PER_SEC * SECS_PER_HOUR )

Definition at line 248 of file mbgtime.h.

◆ SEC100S_PER_MIN

#define SEC100S_PER_MIN   ( SEC100S_PER_SEC * SECS_PER_MIN )

Definition at line 247 of file mbgtime.h.

◆ SEC100S_PER_SEC

#define SEC100S_PER_SEC   100L

Definition at line 246 of file mbgtime.h.

◆ SECS_PER_DAY

#define SECS_PER_DAY   86400L

Definition at line 243 of file mbgtime.h.

Referenced by show_utc_info().

◆ SECS_PER_HOUR

#define SECS_PER_HOUR   3600

◆ SECS_PER_MIN

#define SECS_PER_MIN   60

Definition at line 235 of file mbgtime.h.

◆ SECS_PER_WEEK

#define SECS_PER_WEEK   604800L

Definition at line 244 of file mbgtime.h.

Referenced by show_utc_info().

◆ USEC_PER_SEC

#define USEC_PER_SEC   1000000L

Definition at line 260 of file mbgtime.h.

Referenced by snprint_time_t_to_iso_us().

◆ usec_to_bin_frac_16

#define usec_to_bin_frac_16 (   _usec)    dec_frac_to_bin_frac_16( (_usec), 1000000L )

Definition at line 488 of file mbgtime.h.

◆ usec_to_bin_frac_32

#define usec_to_bin_frac_32 (   _usec)    dec_frac_to_bin_frac_32( (_usec), 1000000L )

Definition at line 485 of file mbgtime.h.

Typedef Documentation

◆ DAYS_OF_MONTH_TABLE

typedef char DAYS_OF_MONTH_TABLE[2][12]

A table with the days of month.

First row is for standard years, second row is for leap years.

See also
DAYS_OF_MONTH_TABLE_INIT

Definition at line 291 of file mbgtime.h.

Function Documentation

◆ bin_frac_16_to_dec_frac()

static __mbg_inline uint32_t bin_frac_16_to_dec_frac ( uint16_t  bin,
uint32_t  scale 
)
static

Convert a 16 bit binary fraction to a scaled decimal.

Parameters
[in]binThe binary fraction
[in]scaleThe scale factor
Returns
The calculated number
See also
dec_frac_to_bin_frac_16
dec_frac_to_bin_frac_32
bin_frac_32_to_dec_frac

Definition at line 417 of file mbgtime.h.

References MBG_FRAC32_CONVERSION_TYPE.

◆ bin_frac_32_to_dec_frac()

static __mbg_inline uint32_t bin_frac_32_to_dec_frac ( uint32_t  bin,
uint32_t  scale 
)
static

Convert a 32 bit binary fraction to a scaled decimal.

Parameters
[in]binThe binary fraction
[in]scaleThe scale factor
Returns
The calculated number
See also
dec_frac_to_bin_frac_32
dec_frac_to_bin_frac_16
bin_frac_16_to_dec_frac

Definition at line 439 of file mbgtime.h.

References MBG_FRAC32_CONVERSION_TYPE, and MBG_FRAC32_UNITS_PER_SEC.

Referenced by do_set_system_time_from_pcps_hr_time(), frac_sec_from_bin(), mbg_snprint_hr_tstamp(), mbg_str_pcps_hr_time_frac(), ntp_tstamp_to_nanotime_64(), and swap_tstamp().

◆ check_timeout()

bit check_timeout ( TIMEOUT t,
clock_t  clk 
)

Check if a timeout object has expired.

Parameters
[in]tThe timeout object
[in]clkThe current time, in clock_t ticks
Returns
1 if timeout expired, else 0

Referenced by dfrac_sec_from_bin().

◆ clear_time()

TM_GPS* clear_time ( TM_GPS tm)

Set the time in a TM_GPS structure to 00:00:00.000.

Parameters
[in,out]tmThe date/time structure to be set
Returns
Pointer to the TM_GPS structure that has been passed

Referenced by dfrac_sec_from_bin().

◆ date_of_year()

void date_of_year ( int  year,
int  day_num,
TM_GPS tm 
)

Compute a date from a given year and day-of-year.

Parameters
[in]yearThe full year number
[in]day_numNumber of days from the beginning of that year, may be negative
[out]tmAddress of a TM_GPS structure which takes the computed results

Referenced by dfrac_sec_from_bin().

◆ day_of_week()

int day_of_week ( int  day,
int  month,
int  year 
)

Compute day-of-week from a given date.

Parameters
[in]dayThe day-of-month
[in]monthThe month
[in]yearThe full year number
Returns
The computed day-of-week
See also
n_days

Referenced by dfrac_sec_from_bin().

◆ day_of_year()

int day_of_year ( int  day,
int  month,
int  year 
)

Compute the day-of-year from a given date.

Parameters
[in]dayThe day-of-month
[in]monthThe month
[in]yearThe full year number
Returns
The computed day-of-year

Referenced by dfrac_sec_from_bin().

◆ days_to_years()

int days_to_years ( long *  day_num,
int  year 
)

Update a year number by a number of days, accounting for leap years.

Parameters
[in]day_numThe number of days to evaluate
[in]yearThe year number to start with
Returns
The computed year number

Referenced by dfrac_sec_from_bin().

◆ dec_frac_to_bin_frac_16()

static __mbg_inline uint16_t dec_frac_to_bin_frac_16 ( uint32_t  dec,
uint32_t  scale 
)
static

Definition at line 458 of file mbgtime.h.

References MBG_FRAC32_CONVERSION_TYPE.

◆ dec_frac_to_bin_frac_32()

static __mbg_inline uint32_t dec_frac_to_bin_frac_32 ( uint32_t  dec,
uint32_t  scale 
)
static

Definition at line 466 of file mbgtime.h.

References MBG_FRAC32_CONVERSION_TYPE, and MBG_FRAC32_UNITS_PER_SEC.

◆ dfrac_sec_from_bin()

static __mbg_inline double dfrac_sec_from_bin ( uint32_t  b)
static

Convert a binary fraction to "double" fractions.

Convert a binary fraction (e.g. of a second, as in PCPS_TIME_STAMP::frac) to a "double" with the units of seconds.
E.g. a 0xFFFFFFFF fraction yields 0.9999999999....

Note
Excluded from build for kernel drivers which usually don't support floating point operations.
Parameters
[in]bThe binary fraction
Returns
The calculated fraction
See also
MBG_FRAC32_UNITS_PER_SEC

Definition at line 534 of file mbgtime.h.

References check_timeout(), clear_time(), date_of_year(), day_of_week(), day_of_year(), days_to_years(), err_tm(), is_leap_year(), MBG_FRAC32_UNITS_PER_SEC, n_days(), set_timeout(), sprint_date(), sprint_day_date(), sprint_short_time(), sprint_time(), sprint_tm(), sscan_date(), sscan_time(), stretch_timeout(), tm_to_wsec(), and wsec_to_tm().

Referenced by get_htc_delta().

◆ err_tm()

int err_tm ( const TM_GPS tm)

Check if a TM_GPS structure contains a valid date and time.

Parameters
[in]tmThe date/time structure to be checked
Returns
0 if date/time is valid, else a negative number indicating which field was found invalid

Referenced by dfrac_sec_from_bin().

◆ frac_sec_from_bin()

static __mbg_inline uint32_t frac_sec_from_bin ( uint32_t  b,
uint32_t  scale 
)
static

Convert a binary fraction to a scaled decimal.

Convert a binary fraction (e.g. of a second, as in PCPS_TIME_STAMP::frac) to a decimal fraction, using a specified scale factor.

Deprecated:
This function is deprecated, use bin_frac_32_to_dec_frac preferably.
Parameters
[in]bThe binary fraction
[in]scaleThe scale factor
Returns
The calculated number
See also
bin_frac_32_to_dec_frac

Definition at line 509 of file mbgtime.h.

References bin_frac_32_to_dec_frac().

◆ is_leap_year()

int is_leap_year ( int  y)

Check if a specific year is a leap year.

Parameters
[in]yThe full year number
Returns
!= 0 if the year is a leap year, else 0

Referenced by dfrac_sec_from_bin().

◆ n_days()

long n_days ( ushort  mday,
ushort  month,
ushort  year 
)

Compute number of days after Jan 1, 0000 for a given date.

Parameters
[in]mdayThe day-of-month
[in]monthThe month
[in]yearThe full year number
Returns
The computed number of days
See also
day_of_week

Referenced by dfrac_sec_from_bin().

◆ set_timeout()

void set_timeout ( TIMEOUT t,
clock_t  clk,
clock_t  interval 
)

Set a timeout object to specified interval.

Parameters
[out]tThe timeout object
[in]clkThe current time, in clock_t ticks
[in]intervalThe interval until expiration, in clock_t ticks

Referenced by dfrac_sec_from_bin().

◆ sprint_date()

int sprint_date ( char *  s,
const TM_GPS tm 
)

Print date to a string.

Parameters
[out]sAddress of a string buffer to be filled
[in]tmAddress of a TM_GPS structure providing date and time

Referenced by dfrac_sec_from_bin().

◆ sprint_day_date()

int sprint_day_date ( char *  s,
const TM_GPS tm 
)

Print day-of-week and date to a string.

Parameters
[out]sAddress of a string buffer to be filled
[in]tmAddress of a TM_GPS structure providing date and time

Referenced by dfrac_sec_from_bin().

◆ sprint_short_time()

int sprint_short_time ( char *  s,
const TM_GPS tm 
)

Print time with hours, minutes to a string.

Parameters
[out]sAddress of a string buffer to be filled
[in]tmAddress of a TM_GPS structure providing date and time

Referenced by dfrac_sec_from_bin().

◆ sprint_time()

int sprint_time ( char *  s,
const TM_GPS tm 
)

Print time with hours, minutes, seconds to a string.

Parameters
[out]sAddress of a string buffer to be filled
[in]tmAddress of a TM_GPS structure providing date and time

Referenced by dfrac_sec_from_bin().

◆ sprint_tm()

int sprint_tm ( char *  s,
const TM_GPS tm 
)

Print day-of-week, date and time to a string.

Parameters
[out]sAddress of a string buffer to be filled
[in]tmAddress of a TM_GPS structure providing date and time

Referenced by dfrac_sec_from_bin().

◆ sscan_date()

void sscan_date ( char *  s,
TM_GPS tm 
)

Extract a date from a string.

Parameters
[in]sA date string in format dd.mm. or dd.mm.yyyy
[out]tmAddress of a TM_GPS structure which takes the extracted date

Referenced by dfrac_sec_from_bin().

◆ sscan_time()

void sscan_time ( const char *  s,
TM_GPS tm 
)

Extract a time from a string.

Parameters
[in]sA time string in format hh:mm:ss
[out]tmAddress of a TM_GPS structure which takes the extracted time

Referenced by dfrac_sec_from_bin().

◆ stretch_timeout()

void stretch_timeout ( TIMEOUT t,
clock_t  interval 
)

Stretch a timeout specified in given timeout object.

Parameters
[in,out]tThe timeout object
[in]intervalThe interval until expiration, in clock_t ticks

Referenced by dfrac_sec_from_bin().

◆ tm_to_wsec()

long tm_to_wsec ( const TM_GPS tm)

Compute second-of-week from day-of-week and time-of-day.

Parameters
[in]tmAddress of a TM_GPS structure providing day-of-week and time-of-day
Returns
The computed second-of-week number
See also
wsec_to_tm

Referenced by dfrac_sec_from_bin().

◆ wsec_to_tm()

TM_GPS* wsec_to_tm ( long  wsec,
TM_GPS tm 
)

Convert second-of-week to day-of-week and time-of-day.

Parameters
[in]wsecThe second-of-week number to be converted
[out]tmAddress of a TM_GPS structure which takes the computed results
Returns
Pointer to the TM_GPS structure that has been passed
See also
tm_to_wsec

Referenced by dfrac_sec_from_bin().

Variable Documentation

◆ date_fmt

const char* date_fmt

◆ datum

TM_GPS datum

◆ day_date_fmt

const char* day_date_fmt

◆ day_name_eng

const char* day_name_eng[]

◆ day_name_ger

const char* day_name_ger[]

◆ days_of_month

DAYS_OF_MONTH_TABLE days_of_month

◆ dhms

TM_GPS dhms

◆ init_tm

const TM_GPS init_tm

◆ long_time_fmt

const char* long_time_fmt

◆ short_time_fmt

const char* short_time_fmt

◆ time_fmt

const char* time_fmt