kstars
Handy formatting and conversion routines.
Functions | |
int | extractISOTime (char *timestr, struct tm *utm) |
int | f_scansexa (const char *str0, double *dp) |
int | fs_sexa (char *out, double a, int w, int fracbase) |
void | getSexComponents (double value, int *d, int *m, int *s) |
double | JDtoGMST (double jd) |
int | numberFormat (char *buf, const char *format, double value) |
const char * | timestamp (void) |
double | UTtoJD (struct tm *utm) |
Function Documentation
int extractISOTime | ( | char * | timestr, | |
struct tm * | utm | |||
) |
Extract ISO 8601 time and store it in a tm struct.
- Parameters:
-
timestr a string containing date and time in ISO 8601 format. utm a pointer to a tm structure to store the extracted time and date.
- Returns:
- 0 on success, -1 on failure.
int f_scansexa | ( | const char * | str0, | |
double * | dp | |||
) |
convert sexagesimal string str AxBxC to double.
x can be anything non-numeric. Any missing A, B or C will be assumed 0. Optional - and + can be anywhere.
- Parameters:
-
str0 string containing sexagesimal number. dp pointer to a double to store the sexagesimal number.
- Returns:
- return 0 if ok, -1 if can't find a thing.
int fs_sexa | ( | char * | out, | |
double | a, | |||
int | w, | |||
int | fracbase | |||
) |
Converts a sexagesimal number to a string.
sprint the variable a in sexagesimal format into out[].
- Parameters:
-
out a pointer to store the sexagesimal number. a the sexagesimal number to convert. w the number of spaces in the whole part. fracbase is the number of pieces a whole is to broken into; valid options:
- 360000: <w>:mm:ss.ss
- 36000: <w>:mm:ss.s
- 3600: <w>:mm:ss
- 600: <w>:mm.m
- 60: <w>:mm
- Returns:
- number of characters written to out, not counting final null terminator.
void getSexComponents | ( | double | value, | |
int * | d, | |||
int * | m, | |||
int * | s | |||
) |
double JDtoGMST | ( | double | jd | ) |
Return the degree, minute, and second components of a sexagesimal number.
- Parameters:
-
value sexagesimal number to decompose. d a pointer to double to store the degrees field. m a pointer to a double to store the minutes field. s a pointer to a double to store the seconds field. Converts Julian Date to Greenwich Sidereal Time. jd The Julian date
- Returns:
- GMST in degrees
int numberFormat | ( | char * | buf, | |
const char * | format, | |||
double | value | |||
) |
Fill buffer with properly formatted INumber string.
- Parameters:
-
buf to store the formatted string. format format in sprintf style. value the number to format.
- Returns:
- length of string.
const char* timestamp | ( | void | ) |
Create an ISO 8601 formatted time stamp.
The format is YYYY-MM-DDTHH:MM:SS
- Returns:
- The formatted time stamp.
double UTtoJD | ( | struct tm * | utm | ) |
Converts Universal Time to Julian Date.
- Parameters:
-
utm a pointer to a structure holding the universal time and date.
- Returns:
- The Julian date fot the passed universal time.