/** * Week number magic * * @file platon/misc/week.h * @author Daniel Stenberg * @version \$Platon: libplaton/platon/misc/week.h,v 1.5 2002/10/05 09:50:57 nepto Exp $ * @date 1998-2003 */ /* ISO 8601 - Week Number Magic Copyright (C) 1998 by Daniel Stenberg, All Rights Reserved Version 1.2 Nov 18, 1998 - Magnus Tjernstrom brought my attention to a weird 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. 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 */ #ifndef _PLATON_MISC_WEEK_H #define _PLATON_MISC_WEEK_H #ifdef __cplusplus extern "C" { #endif /** * Returns week and weekday according to date in year/month/day * * @param year year to query * @param month month to query * @param day day to query * @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 * * Weekdays started from Monday. It means that weekday 1 is Monday, * weekday 2 is Tuesday, and so on. */ int week(int year, int month, int day, int *aweek, int *weekday); /** * 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 } #endif #endif /* #ifndef _PLATON_MISC_WEEK_H */