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
67struct tm;
68
69namespace wibble {
70namespace grcal {
71
75namespace date {
76
80void today(int* dst);
81
83void now(int* dst);
84
86int daysinmonth(int year, int month);
87
89int daysinyear(int year);
90
97void easter(int year, int* month, int* day);
98
103void lowerbound(const int* src, int* dst);
104
109void lowerbound(int* val);
110
115void upperbound(const int* src, int* dst);
116
121void upperbound(int* val);
122
142void normalise(int* res);
143
151long long int secondsfrom(int year, const int* val);
152
158long long int duration(const int* begin, const int* end);
159
165void mergetime(const int* date, const int* time, int* dst);
166
172void mergetime(int* date, const int* time);
173
177void totm(const int* src, struct tm* dst);
178
183void fromtm(const struct tm& src, int* dst, int count = 6);
184
188std::string tostring(const int* val);
189
190}
191
195namespace dtime {
196
201void lowerbound(const int* src, int* dst);
202
207void lowerbound(int* val);
208
213int lowerbound_sec(const int* src);
214
215
220void upperbound(const int* src, int* dst);
221
226void upperbound(int* val);
227
232int upperbound_sec(const int* src);
233
240int duration(const int* begin, const int* end);
241
245std::string tostring(const int* val);
246
250std::string tostring(int val);
251
252}
253
254}
255}
256
257// vim:set ts=4 sw=4:
258#endif
void totm(const int *src, struct tm *dst)
Copy the values from an int[6] datetime into a struct tm.
Definition grcal.cpp:281
std::string tostring(const int *val)
Convert a datetime to a string.
Definition grcal.cpp:319
int daysinyear(int year)
Return the number of days in a year.
Definition grcal.cpp:84
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
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
void now(int *dst)
Fill in an int[6] with the UTC values for now.
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
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
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 today(int *dst)
Fill in an int[6] with the UTC values for today (leaving the time of day elements to -1)
int daysinmonth(int year, int month)
Return the number of days in a month.
Definition grcal.cpp:57
void normalise(int *res)
Normalise a datetime, in place.
Definition grcal.cpp:145
void easter(int year, int *month, int *day)
Compute the day of Easter.
Definition grcal.cpp:91
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 lowerbound(const int *src, int *dst)
Make a copy of the time, filling in missing values with the lowest possible value they can have.
Definition grcal.cpp:341
std::string tostring(const int *val)
Format a time of day to a string.
Definition grcal.cpp:391
int duration(const int *begin, const int *end)
Give the duration in seconds of the interval between the end of begin and the beginning of end.
Definition grcal.cpp:386
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
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 upperbound(const int *src, int *dst)
Make a copy of the time, filling in missing values with the highest possible value they can have.
Definition grcal.cpp:363
Definition amorph.h:17
Definition amorph.h:30