PLplot  5.9.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
pltime.c
Go to the documentation of this file.
1 // $Id: pltime.c 11680 2011-03-27 17:57:51Z airwin $
2 //
3 // Routines for interfacing with qsastime library routines.
4 //
5 // Copyright (C) 2009 Alan W. Irwin
6 //
7 // This file is part of PLplot.
8 //
9 // PLplot is free software; you can redistribute it and/or modify
10 // it under the terms of the GNU Library General Public License as published
11 // by the Free Software Foundation; either version 2 of the License, or
12 // (at your option) any later version.
13 //
14 // PLplot is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU Library General Public License for more details.
18 //
19 // You should have received a copy of the GNU Library General Public License
20 // along with PLplot; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 //
23 
24 #include "plplotP.h"
25 
26 // Calculate broken-down time from continuous time for current stream.
27 void
28 c_plbtime( PLINT *year, PLINT *month, PLINT *day, PLINT *hour, PLINT *min, PLFLT *sec, PLFLT ctime )
29 {
30  btimeqsas( year, month, day, hour, min, sec, ctime, plsc->qsasconfig );
31 }
32 
33 // Configure transformation between continuous and broken-down time (and
34 // vice versa) for current stream.
35 void
36 c_plconfigtime( PLFLT scale, PLFLT offset1, PLFLT offset2, PLINT ccontrol, PLBOOL ifbtime_offset, PLINT year, PLINT month, PLINT day, PLINT hour, PLINT min, PLFLT sec )
37 {
38  if ( scale == 0. )
39  {
40  // Default transformation between continuous and broken-down time
41  // (and vice versa) defined here for PLplot.
42  // Note the PLplot default is not necessarily the same as the
43  // libqsastime default.
44  configqsas( 1. / 86400., 0., 0., 0x0, 1, 1970, 0, 1, 0, 0, 0., &( plsc->qsasconfig ) );
45  }
46  else
47  {
48  configqsas( scale, offset1, offset2, ccontrol, ifbtime_offset, year, month, day, hour, min, sec, &( plsc->qsasconfig ) );
49  }
50 }
51 
52 // Calculate continuous time from broken-down time for current stream.
53 void
54 c_plctime( PLINT year, PLINT month, PLINT day, PLINT hour, PLINT min, PLFLT sec, PLFLT *ctime )
55 {
56  int ret;
57  ret = ctimeqsas( year, month, day, hour, min, sec, ctime, plsc->qsasconfig );
58  if ( ret )
59  plabort( "plctime: ctimeqsas detected error" );
60 }
61 
62 // Set format for date / time labels.
63 void
64 c_pltimefmt( const char *fmt )
65 {
66  if ( plsc->timefmt )
67  free_mem( plsc->timefmt );
68 
69  plsc->timefmt = (char *) malloc( (size_t) ( strlen( fmt ) + 1 ) );
70  strcpy( plsc->timefmt, fmt );
71 }
72 
int min(int a, int b)
int ctimeqsas(int year, int month, int day, int hour, int min, double sec, double *ctime, QSASConfig *qsasconfig)
Definition: qsastime.c:1210
void configqsas(double scale, double offset1, double offset2, int ccontrol, int ifbtime_offset, int year, int month, int day, int hour, int min, double sec, QSASConfig **qsasconfig)
Definition: qsastime.c:1142
void c_plctime(PLINT year, PLINT month, PLINT day, PLINT hour, PLINT min, PLFLT sec, PLFLT *ctime)
Definition: pltime.c:54
void c_plbtime(PLINT *year, PLINT *month, PLINT *day, PLINT *hour, PLINT *min, PLFLT *sec, PLFLT ctime)
Definition: pltime.c:28
int PLINT
Definition: plplot.h:175
PLINT PLBOOL
Definition: plplot.h:198
void c_pltimefmt(const char *fmt)
Definition: pltime.c:64
void plabort(const char *errormsg)
Definition: plctrl.c:1877
float PLFLT
Definition: plplot.h:159
#define free_mem(a)
Definition: plplotP.h:187
void c_plconfigtime(PLFLT scale, PLFLT offset1, PLFLT offset2, PLINT ccontrol, PLBOOL ifbtime_offset, PLINT year, PLINT month, PLINT day, PLINT hour, PLINT min, PLFLT sec)
Definition: pltime.c:36
void btimeqsas(int *year, int *month, int *day, int *hour, int *min, double *sec, double ctime, QSASConfig *qsasconfig)
Definition: qsastime.c:1233