AcePerl

 view release on metacpan or  search on metacpan

acelib/timesubs.c  view on Meta::CPAN

/*  File: timesubs.c
 *  Author: Richard Durbin (rd@mrc-lmb.cam.ac.uk)
 *  Copyright (C) J Thierry-Mieg and R Durbin, 1991
 *-------------------------------------------------------------------
 * This file is part of the ACEDB genome database package, written by
 * 	Richard Durbin (MRC LMB, UK) rd@mrc-lmb.cam.ac.uk, and
 *	Jean Thierry-Mieg (CRBM du CNRS, France) mieg@kaa.cnrs-mop.fr
 *
 * Description: functions to handle times/dates

   * mieg, mars 94: timeParse/timeShow
      this pair of functions is to be used in conjunction
      with the _DateType fundamental type which can
      now be used in the same way as _Int _Float in models.wrm

 * HISTORY:
 * Last edited: Nov 27 13:19 1998 (fw)
 * * Jul  9 17:23 1998 (fw): added timeComparison() function for < , = and > operators
 * * Jul  8 15:49 1998 (fw): added timeDiff functions for mins,hours,months,years
                             as required by the new AQL date-functions
 * * Jan 29 22:31 1995 (rd): allow "today"  like "now", for day only
 * * Nov 13 19:04 1994 (rd): allow date abbreviations, and rename 
 	consistently, and removed timeStamp, dateStamp
 * * Jun 21 17:12 1992 (mieg): changed : to _ in time stamped
   : was preventing the file chooser from reading in a dump file
 * * Jan 20 10:46 1992 (mieg): Fixed  timeStamp, dateStamp
    and removed everything else with an ifdef
 * Created: a long time ago
 *-------------------------------------------------------------------
 */

/* $Id: timesubs.c,v 1.1 2002/11/14 20:00:06 lstein Exp $ */

#include "regular.h"
#include "mytime.h"
#include <time.h>

/* 
----------------------------------------------------------------------
Time string formats
1994-07-17_20:16:11     -- dumped and read
now                     -- replaced with current date and time
today                   -- replaced with current date only
94-07-17_20:16:11       -- interpreted as 1994-07-17_20:16:11

any left abbreviation of the above, e.g. 94-07-17, or 94-07 is also 
read, and when dumping any trailing 0 fields are ommitted.

the _ is optional, can be one blank

How to deal with timezones:

The internal time is always in GMT (Greenwich Mean Time) (an
alias for GMT is UTC (Coordinated Universal Time)).

For the external format I could not find a notation which shows
the local time and is easly convertable into internal time again on
every computer.

Therefore I left out the timezone information from the external format.
I leave it to the user what he wants:
While working locally or exchanging data within one timezone, there
is no fuss at all.
When transfering data across the ocean with the wish to keep the time
accurate, one can use this scheme:

1. in Montpellier:
   csh                 // opening an extra shell saves the environment
   setenv TZ GMT
   start xace/tace and dump into file.ace
   transfer file
   exit                // back in local timezone
2. in Berkeley:
   csh
   setenv TZ GMT
   use xace/tace to read file.ace
   exit



( run in 0.697 second using v1.01-cache-2.11-cpan-ceb78f64989 )