das2/das1.h File Reference

Das 1 Utilities Basic Das utilities. More...


Detailed Description

Das 1 Utilities Basic Das utilities.

Many of these are utilized by the Das2 utilities.

#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

Go to the source code of this file.

Data Structures

struct  das_time_t
 Basic date-time structure used throughout the Das1 & Das2 utilities. More...

Functions

void _swapBufInPlace (void *pMem, size_t szEach, size_t numItems)
 Swap whole buffers in place.
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.
int past_1958 (int year, int day)
 Get the number of days since 1958-01-01 given a year and day of year.
double ttime (int *year, int *month, int *mday, int *yday, int *hour, int *minute, double *second)
 Convert time components to double seconds since epoch.
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.
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.
void yrdy1958 (int *pYear, int *pDoy, int days_since_1958)
 Return a year and day of year given the number of days past 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.

Function Documentation

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 accomodation 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.

Note:
that day-of-year (yday) is an output-only parameter for all of these functions. To use day-of-year as input, set month to 1 and pass day-of-year in mday instead.
Warning:
This function can change it's input values! The time will be normalized this could change the input time.
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.

Parameters:
[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] 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.

Parameters:
[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.
 All Data Structures Files Functions Variables Typedefs Enumerations Defines

Generated on 11 Sep 2016 for Das2 Stream Utilities by  doxygen 1.6.1