PLplot  5.11.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
pltime.c
Go to the documentation of this file.
1 // Routines for interfacing with qsastime library routines.
2 //
3 // Copyright (C) 2009-2014 Alan W. Irwin
4 //
5 // This file is part of PLplot.
6 //
7 // PLplot is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU Library General Public License as published
9 // by the Free Software Foundation; either version 2 of the License, or
10 // (at your option) any later version.
11 //
12 // PLplot is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Library General Public License for more details.
16 //
17 // You should have received a copy of the GNU Library General Public License
18 // along with PLplot; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 //
21 
22 #include "plplotP.h"
23 
24 // Calculate broken-down time from continuous time for current stream.
25 void
26 c_plbtime( PLINT *year, PLINT *month, PLINT *day, PLINT *hour, PLINT *min, PLFLT *sec, PLFLT ctime )
27 {
28  double qsas_sec;
29  btimeqsas( year, month, day, hour, min, &qsas_sec, ctime, plsc->qsasconfig );
30  *sec = (PLFLT) qsas_sec;
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  double qsas_ctime;
58  ret = ctimeqsas( year, month, day, hour, min, sec, &qsas_ctime, plsc->qsasconfig );
59  *ctime = (PLFLT) qsas_ctime;
60  if ( ret )
61  plabort( "plctime: ctimeqsas detected error" );
62 }
63 
64 // Set format for date / time labels.
65 void
66 c_pltimefmt( const char *fmt )
67 {
68  if ( plsc->timefmt )
69  free_mem( plsc->timefmt );
70 
71  plsc->timefmt = (char *) malloc( (size_t) ( strlen( fmt ) + 1 ) );
72  strcpy( plsc->timefmt, fmt );
73 }
74 
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:26
int PLINT
Definition: plplot.h:174
PLINT PLBOOL
Definition: plplot.h:197
void c_pltimefmt(const char *fmt)
Definition: pltime.c:66
void plabort(const char *errormsg)
Definition: plctrl.c:1884
float PLFLT
Definition: plplot.h:157
#define free_mem(a)
Definition: plplotP.h:182
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