| version 1.2, 2002/02/04 18:38:11 |
version 1.3, 2002/09/19 23:18:00 |
|
|
| #ifndef _PLATON_UTILS_WEEK_H |
/** |
| #define _PLATON_UTILS_WEEK_H |
* @file misc/week.h |
| |
* @brief Week number magic |
| |
* @author Daniel Stenberg |
| |
* @version \$Id$ |
| |
* @date 1998-2002 |
| |
*/ |
| |
|
| |
#ifndef _PLATON_MISC_WEEK_H |
| |
#define _PLATON_MISC_WEEK_H |
| |
|
| /* |
/* |
| ISO 8601 - Week Number Magic |
ISO 8601 - Week Number Magic |
|
|
| - Magnus Tjernstrom <d92-mtm@ludd.luth.se> brought my attention to a weird |
- Magnus Tjernstrom <d92-mtm@ludd.luth.se> brought my attention to a weird |
| treatment of the last days of a year, treated as week 53 before when they |
treatment of the last days of a year, treated as week 53 before when they |
| really should be week 1. I believe I've corrected that now. |
really should be week 1. I believe I've corrected that now. |
| */ |
|
| /* |
|
| Self test notes: |
|
| |
|
| According to my tries, weekdays are started from Monday, |
|
| so that means Weekday 1 is Monday, Weekday 2 Tuesday, and so on. |
|
| |
|
| Ondrej Jombik <nepto@pobox.sk> |
Updates: |
| |
14/11/2001 (Week 46 Weekday 3, Wed) - initial release |
| |
04/02/2002 (Week 6 Weekday 1, Mon) - import to CVS |
| |
20/09/2002 (Week 38 Weekday 5, Fri) - Doxygen documentation |
| |
|
| Updates: |
|
| 14/11/2001 (Week 46 Weekday 3, Wed) - initial release |
|
| 04/02/2001 (Week 6 Weekday 1, Mon) - import to CVS |
|
| */ |
*/ |
| |
|
| #ifdef __cplusplus |
#ifdef __cplusplus |
| extern "C" { |
extern "C" { |
| #endif |
#endif |
| |
|
| /* |
/** |
| * week() |
* Returns week and weekday according to date in year/month/day |
| * |
* |
| * Sets week and weekday according to date in year/month/day. |
* @param year year to query |
| * Returns non-zero if it failed, zero if OK. |
* @param month month to query |
| */ |
* @param day day to query |
| int week(int year, int month, int day, int *aweek, int *weekday); |
* @retval aweek pointer to int where to store week number |
| |
* @retval weekday pointer to int where to store weekday number |
| /* |
* @return non-zero value on failure, zero if all OK |
| * week_no() |
* |
| * |
* Weekdays started from Monday. It means that weekday 1 is Monday, |
| * Sets monday of week in year to ret_month and ret_day. Year is the same. |
* weekday 2 is Tuesday, and so on. |
| * If value of week is more than 53, it is truncated. Returns always 0. |
*/ |
| */ |
int week(int year, int month, int day, int *aweek, int *weekday); |
| int week_no(int year, int aweek, int *ret_month, int *ret_day); |
|
| |
/** |
| |
* Returns monday of week in year |
| |
* |
| |
* @param year year to query |
| |
* @param aweek number of week to query |
| |
* @retval ret_month pointer to int where to store monday month |
| |
* @retval ret_day pointer to int where to store monday day |
| |
* @return allways 0 |
| |
* |
| |
* Year of resulted monday is the same as the year of queried week, what is |
| |
* passed to function as year parameter. If value of aweek is more than |
| |
* 53, it is truncated. |
| |
*/ |
| |
int week_no(int year, int aweek, int *ret_month, int *ret_day); |
| |
|
| #ifdef __cplusplus |
#ifdef __cplusplus |
| } |
} |
| #endif |
#endif |
| |
|
| #endif /* #ifndef _PLATON_UTILS_WEEK_H */ |
#endif /* #ifndef _PLATON_MISC_WEEK_H */ |
| |
|