libtws 3 "08 November 1986"

Table of contents


libtws - alternate date and time routines including parsing


include "tws.h"

^struct tws *dlocaltime( clock );~^/* local clock into tws */
long *clock;

^struct tws *gmtime( clock );~^/* GMT clock into tws */
long *clock;

^char *dtime( clock );~^/* clock into string */
long *clock;

^long twclock( t );~^/* tws into clock */
struct tws *t;

^long twjuliandate( t );~^/* tws into Julian day number */
struct tws *t;

^struct tws *dparsetime( str );~^/* string into tws */
char *str;

^char *dctime( t );~^/* tws into string */
struct tws *t;

^char *dasctime( t, flags );~^/* tws into string */
struct tws *t;
int flags;

^char *dtimezone( offset, flags );~^/* timezone into string */
int offset, flags;

^char *dtwszone( t );~^/* tws's timezone into string */
struct tws *t;

^char *dtimemow( );~^/* current time into string */

^struct tws *dtwstime( );~^/* current time into tws */

^void twscopy( tot, fromt );~^/* copy a tws */
struct tws *tot, *fromt;

^int twsort( t1, t2 );~^/* compare two tws's */
struct tws *t1, *t2;

^long twsubtract( t1, t2 );~^/* seconds between t2 and t1 */
struct tws *t1, *t2;


Libtws is a fairly complete date/time library. Unlike the standard Unix* date/time routines, libtws will parse date/time strings into internal form. The format for specifying date/time strings is pretty loose - basically the same as the format for date/times in network mail.

Most of the routines do not use the Unix* "clock" time format, and therefore are not limited to dates after 01 January 1970. In particular, twsubtract() lets you subtract two dates without converting them to "clock" form.


ctime(3), time(3)


Most of libtws came from version 6.5 of the MH message handling system, courtesy of Marshall Rose. Some improvements (?) were added by Jef Poskanzer.


The return values point to static data whose contents are overwritten by the next call.

The basic Unix* time format (clock) only goes back to 1970, limiting applications somewhat.


* Unix is a virus from outer space.