PLplot  5.10.0
 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  btimeqsas( year, month, day, hour, min, sec, ctime, plsc->qsasconfig );
29 }
30 
31 // Configure transformation between continuous and broken-down time (and
32 // vice versa) for current stream.
33 void
34 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 )
35 {
36  if ( scale == 0. )
37  {
38  // Default transformation between continuous and broken-down time
39  // (and vice versa) defined here for PLplot.
40  // Note the PLplot default is not necessarily the same as the
41  // libqsastime default.
42  configqsas( 1. / 86400., 0., 0., 0x0, 1, 1970, 0, 1, 0, 0, 0., &( plsc->qsasconfig ) );
43  }
44  else
45  {
46  configqsas( scale, offset1, offset2, ccontrol, ifbtime_offset, year, month, day, hour, min, sec, &( plsc->qsasconfig ) );
47  }
48 }
49 
50 // Calculate continuous time from broken-down time for current stream.
51 void
52 c_plctime( PLINT year, PLINT month, PLINT day, PLINT hour, PLINT min, PLFLT sec, PLFLT *ctime )
53 {
54  int ret;
55  ret = ctimeqsas( year, month, day, hour, min, sec, ctime, plsc->qsasconfig );
56  if ( ret )
57  plabort( "plctime: ctimeqsas detected error" );
58 }
59 
60 // Set format for date / time labels.
61 void
62 c_pltimefmt( const char *fmt )
63 {
64  if ( plsc->timefmt )
65  free_mem( plsc->timefmt );
66 
67  plsc->timefmt = (char *) malloc( (size_t) ( strlen( fmt ) + 1 ) );
68  strcpy( plsc->timefmt, fmt );
69 }
70