GRASS Programmer's Manual
6.4.2(2012)
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
tz2.c
Go to the documentation of this file.
1
/*
2
* Copyright (C) 1995. Bill Brown <brown@gis.uiuc.edu> & Michael Shapiro
3
*
4
* This program is free software under the GPL (>=v2)
5
* Read the file GPL.TXT coming with GRASS for details.
6
*/
7
#include <grass/datetime.h>
8
9
24
int
datetime_change_timezone
(DateTime * dt,
int
minutes)
25
{
/* new timezone in minutes */
26
int
stat;
27
int
old_minutes, diff_minutes;
28
DateTime incr;
29
30
stat =
datetime_get_timezone
(dt, &old_minutes);
31
if
(stat != 0)
32
return
stat;
33
if
(!
datetime_is_valid_timezone
(minutes))
34
return
datetime_error
(-4,
"invalid datetime timezone"
);
35
36
/* create a relative minute increment */
37
datetime_set_type
(&incr, DATETIME_RELATIVE, DATETIME_MINUTE,
38
DATETIME_MINUTE, 0);
39
40
/* BB - needed to set SIGN here */
41
diff_minutes = minutes - old_minutes;
42
if
(diff_minutes >= 0) {
43
datetime_set_minute
(&incr, diff_minutes);
44
}
45
else
{
46
datetime_invert_sign
(&incr);
47
datetime_set_minute
(&incr, -diff_minutes);
48
}
49
50
return
datetime_increment
(dt, &incr);
51
}
52
53
63
int
datetime_change_to_utc
(DateTime * dt)
64
{
65
return
datetime_change_timezone
(dt, 0);
66
}
67
68
87
void
datetime_decompose_timezone
(
int
tz,
int
*hours,
int
*minutes)
88
{
89
if
(tz < 0)
90
tz = -tz;
91
92
*hours = tz / 60;
93
*minutes = tz % 60;
94
}
lib
datetime
tz2.c
Generated on Wed Jun 6 2012 14:04:29 for GRASS Programmer's Manual by
1.8.1