aboutsummaryrefslogtreecommitdiff
path: root/src/util.cpp
blob: 6107bdb3ee4ba33102c684a015f72978ebdabf89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "bu/util.h"

int Bu::getDaysInMonth( int iMonth, int iYear )
{
	if( iMonth > 11 )
	{
		iYear += iMonth/12;
		iMonth = iMonth%12;
	}
	switch( iMonth )
	{
	case 0:
	case 2:
	case 4:
	case 6:
	case 7:
	case 9:
	case 11:
		return 31;
		break;

	case 3:
	case 5:
	case 8:
	case 10:
		return 30;
		break;

	case 1:
		if( iYear%400 == 0 )
			return 29;
		if( iYear%100 == 0 )
			return 28;
		if( iYear%4 == 0 )
			return 29;
		return 28;
		break;

	default:
		return -1;
	}
}
void Bu::memcpy( void *pDest, const void *pSrc, size_t iBytes )
{
#ifdef VALTEST
	const char *src = (const char *)pSrc;
	char *dest = (char *)pDest;
	for( int j = 0; j < count; j++ )
	{
		*dest = *src;
		dest++;
		src++;
	}
#else
	::memcpy( pDest, pSrc, iBytes );
#endif
}