Example #1
0
// day_of_week -
//	Returns the day of week.
//	Taken from PHP source code.
static int  day_of_week ( int  year, int  month, int  day, int  iso )
   {
	int	c1, y1, m1, dow ;

	c1	=  century_value ( year / 100 ) ;
	y1	=  positive_mod ( year, 100 ) ;
	m1	=  IS_LEAP ( year ) ?  leap_year_table [ month ] : nonleap_year_table [ month ] ;

	dow	=  positive_mod ( ( c1 + y1 + m1 + ( y1 / 4 ) + day ), 7) ;

	if  ( iso )
	   {
		if  ( ! dow )
			dow	=  7 ;
	    }

	return ( dow ) ;
    }
Example #2
0
File: dow.c Project: 0x1111/php-src
static timelib_sll timelib_day_of_week_ex(timelib_sll y, timelib_sll m, timelib_sll d, int iso)
{
	timelib_sll c1, y1, m1, dow;

	/* Only valid for Gregorian calendar, commented out as we don't handle
	 * Julian calendar. We just return the 'wrong' day of week to be
	 * consistent. */
	c1 = century_value(y / 100);
	y1 = (y % 100);
	m1 = timelib_is_leap(y) ? m_table_leap[m] : m_table_common[m];
	dow = (c1 + y1 + m1 + (y1 / 4) + d) % 7;
	if (iso) {
		if (dow == 0) {
			dow = 7;
		}
	}
	return dow;
}