GRASS Programmer's Manual
6.4.3(2013)-r
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Macros
Pages
misc.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
18
int
datetime_is_leap_year
(
int
year,
int
ad)
19
{
20
if
(year == 0)
21
return
datetime_error
(-1,
"datetime_is_leap_year(): illegal year"
);
22
if
(!ad)
23
return
0;
/* BC */
24
if
(year < 0)
25
return
0;
/* ?? */
26
27
return
((year % 4 == 0 && year % 100 != 0) || year % 400 == 0);
28
}
29
30
41
int
datetime_days_in_year
(
int
year,
int
ad)
42
{
43
if
(year == 0)
44
return
datetime_error
(-1,
"datetime_days_in_year(): illegal year"
);
45
46
if
(
datetime_is_leap_year
(year, ad))
47
return
366;
48
else
49
return
365;
50
}
51
52
64
int
datetime_days_in_month
(
int
year,
int
month,
int
ad)
65
{
66
static
int
days[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
67
68
if
(month < 1 || month > 12)
69
return
datetime_error
(-1,
"datetime_days_in_month(): illegal month"
);
70
71
if
(month == 2 &&
datetime_is_leap_year
(year, ad))
72
return
(29);
73
74
return
(days[month - 1]);
75
}
lib
datetime
misc.c
Generated on Thu Sep 26 2013 09:48:04 for GRASS Programmer's Manual by
1.8.4