libdas2
das2 core C utilities
|
Das 1 Compatability Utilities. More...
Das 1 Compatability Utilities.
Go to the source code of this file.
Functions | |
void | _swapBufInPlace (void *pMem, size_t szEach, size_t numItems) |
Swap whole buffers in place. | |
float | swapFloat (float rIn) |
Swap single floats, returns new float. | |
int | parsetime (const char *string, int *year, int *month, int *mday, int *yday, int *hour, int *minute, double *second) |
Convert most human-parseable time strings to numeric components returns 0 on success and non-zero on failure. | |
double | ttime (int *year, int *month, int *mday, int *yday, int *hour, int *minute, double *second) |
Convert time components to double seconds since epoch. More... | |
void | emitt (double tt, int *year, int *month, int *mday, int *yday, int *hour, int *minute, double *second) |
convert double seconds since epoch to time components. More... | |
void | tnorm (int *year, int *month, int *mday, int *yday, int *hour, int *minute, double *second) |
normalize date and time components NOTE: yday is OUTPUT only. More... | |
void | yrdy1958 (int *pYear, int *pDoy, int days_since_1958) |
Return a year and day of year given the number of days past 1958. More... | |
int | past_1958 (int year, int day) |
Get the number of days since 1958-01-01 given a year and day of year. | |
void | ms2hms (int *pHour, int *pMin, float *pSec, double ms_of_day) |
Return the hours, minutes and seconds of a day given then number of milliseconds since the start of the day. More... | |
int | getpkt (char *ph, void *data, int max) |
Read a Tagged Das 1 packet from stdin. More... | |
int | fgetpkt (FILE *fin, char *ph, void *data, int max) |
Read a Tagged Das 1 packet from a file object. More... | |
int | putpkt (const char *ph, const void *data, int bytes) |
Write das packet to stdout. More... | |
double ttime | ( | int * | year, |
int * | month, | ||
int * | mday, | ||
int * | yday, | ||
int * | hour, | ||
int * | minute, | ||
double * | second | ||
) |
Convert time components to double seconds since epoch.
Converts time components to a double precision floating point value (seconds since the beginning of 1958, ignoring leap seconds) and normalize inputs. Note that this floating point value should only be used for "internal" purposes. (There's no need to propagate yet another time system, plus I want to be able to change/fix these values.)
There is no accommodation for calendar adjustments, for example the transition from Julian to Gregorian calendar, so I wouldn't recommend using these routines for times prior to the 1800's. Sun IEEE 64-bit floating point preserves millisecond accuracy past the year 3000. For various applications, it may be wise to round to nearest millisecond (or microsecond, etc.) after the value is returned.
void emitt | ( | double | tt, |
int * | year, | ||
int * | month, | ||
int * | mday, | ||
int * | yday, | ||
int * | hour, | ||
int * | minute, | ||
double * | second | ||
) |
convert double seconds since epoch to time components.
emitt (ttime backwards) converts double precision seconds (since the beginning of 1958, ignoring leap seconds) to date and time components.
void tnorm | ( | int * | year, |
int * | month, | ||
int * | mday, | ||
int * | yday, | ||
int * | hour, | ||
int * | minute, | ||
double * | second | ||
) |
normalize date and time components NOTE: yday is OUTPUT only.
To add a day to a time, increment mday as much as needed and then call tnorm.
void yrdy1958 | ( | int * | pYear, |
int * | pDoy, | ||
int | days_since_1958 | ||
) |
Return a year and day of year given the number of days past 1958.
This function is useful for years 1958 to 2096, for years greater than 2096 it runs off the end of an internal buffer.
[out] | pYear | a pointer to an integer to receive the 4 digit year number |
[out] | pDoy | a pointer to an integer to recieve the day of year number (1 = Jan. 1st) |
[in] | days_since_1958 | The number of days since Jan. 1st, 1958 |
void ms2hms | ( | int * | pHour, |
int * | pMin, | ||
float * | pSec, | ||
double | ms_of_day | ||
) |
Return the hours, minutes and seconds of a day given then number of milliseconds since the start of the day.
[out] | pHour | a pointer to an integer to receive the hour of the day (midnight = 0) |
[out] | pMin | a pointer to an integer to receive the minute of the hour. |
[out] | pSec | a pointer to a float to receive the seconds of the minute. Result is (of course) accurate to milliseconds. |
[in] | ms_of_day | the milliseconds of day value. |
int getpkt | ( | char * | ph, |
void * | data, | ||
int | max | ||
) |
Read a Tagged Das 1 packet from stdin.
ph | 8-byte packet header |
data | buffer, |
max | number of bytes to read |
int fgetpkt | ( | FILE * | fin, |
char * | ph, | ||
void * | data, | ||
int | max | ||
) |
Read a Tagged Das 1 packet from a file object.
[in] | fin | input file pointer |
[out] | ph | pointer to buffer to receive the 8-byte packet header |
[out] | data | buffer, |
[in] | max | number of bytes to read |
int putpkt | ( | const char * | ph, |
const void * | data, | ||
int | bytes | ||
) |
Write das packet to stdout.
ph | 8-byte packet header, ex: ":b0:78F2" |
data | buffer |
bytes | number of bytes to write (why this isn't taken from the packet header I don't know) |