wibble  1.1
grcal.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 #ifndef WIBBLE_GRCAL_GRCAL_H
3 #define WIBBLE_GRCAL_GRCAL_H
4 
5 /*
6  * Gregorian calendar functions
7  *
8  * Copyright (C) 2007--2008 Enrico Zini <enrico@debian.org>
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  */
24 
25 #include <string>
26 
67 struct tm;
68 
69 namespace wibble {
70 namespace grcal {
71 
75 namespace date {
76 
80 void today(int* dst);
81 
83 void now(int* dst);
84 
86 int daysinmonth(int year, int month);
87 
89 int daysinyear(int year);
90 
97 void easter(int year, int* month, int* day);
98 
103 void lowerbound(const int* src, int* dst);
104 
109 void lowerbound(int* val);
110 
115 void upperbound(const int* src, int* dst);
116 
121 void upperbound(int* val);
122 
142 void normalise(int* res);
143 
151 long long int secondsfrom(int year, const int* val);
152 
158 long long int duration(const int* begin, const int* end);
159 
165 void mergetime(const int* date, const int* time, int* dst);
166 
172 void mergetime(int* date, const int* time);
173 
177 void totm(const int* src, struct tm* dst);
178 
183 void fromtm(const struct tm& src, int* dst, int count = 6);
184 
188 std::string tostring(const int* val);
189 
190 }
191 
195 namespace dtime {
196 
201 void lowerbound(const int* src, int* dst);
202 
207 void lowerbound(int* val);
208 
213 int lowerbound_sec(const int* src);
214 
215 
220 void upperbound(const int* src, int* dst);
221 
226 void upperbound(int* val);
227 
232 int upperbound_sec(const int* src);
233 
240 int duration(const int* begin, const int* end);
241 
245 std::string tostring(const int* val);
246 
250 std::string tostring(int val);
251 
252 }
253 
254 }
255 }
256 
257 // vim:set ts=4 sw=4:
258 #endif
long long int duration(const int *begin, const int *end)
Give the duration in seconds of the interval between begin and end.
Definition: grcal.cpp:245
void mergetime(const int *date, const int *time, int *dst)
Make a copy of date, with the time part taken from time.
Definition: grcal.cpp:264
long long int secondsfrom(int year, const int *val)
Convert the given time in seconds elapsed since the beginning of the given year.
Definition: grcal.cpp:229
int upperbound_sec(const int *src)
Convert a time of day in second, filling the missing values with the highest possible value they can ...
Definition: grcal.cpp:377
void fromtm(const struct tm &src, int *dst, int count)
Copy the values from a struct tm to the first count values of the int[6] dst.
Definition: grcal.cpp:291
void totm(const int *src, struct tm *dst)
Copy the values from an int[6] datetime into a struct tm.
Definition: grcal.cpp:281
void now(int *dst)
Fill in an int[6] with the UTC values for now.
ListIterator< List > begin(List l)
Definition: list.h:420
void today(int *dst)
Fill in an int[6] with the UTC values for today (leaving the time of day elements to -1) ...
void upperbound(const int *src, int *dst)
Make a copy of the datetime, filling in missing values with the highest possible value they can have...
Definition: grcal.cpp:191
size_t count(List l)
Definition: list.h:341
void easter(int year, int *month, int *day)
Compute the day of Easter.
Definition: grcal.cpp:91
int lowerbound_sec(const int *src)
Convert a time of day in second, filling the missing values with the lowest possible value they can h...
Definition: grcal.cpp:353
std::string tostring(const int *val)
Convert a datetime to a string.
Definition: grcal.cpp:319
void normalise(int *res)
Normalise a datetime, in place.
Definition: grcal.cpp:145
void lowerbound(const int *src, int *dst)
Make a copy of the datetime, filling in missing values with the lowest possible value they can have...
Definition: grcal.cpp:112
Definition: amorph.h:17
int daysinmonth(int year, int month)
Return the number of days in a month.
Definition: grcal.cpp:57
int daysinyear(int year)
Return the number of days in a year.
Definition: grcal.cpp:84
ListIterator< List > end(List)
Definition: list.h:425