aboutsummaryrefslogtreecommitdiff
path: root/src/stable/util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/stable/util.cpp')
-rw-r--r--src/stable/util.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/stable/util.cpp b/src/stable/util.cpp
new file mode 100644
index 0000000..6983dfd
--- /dev/null
+++ b/src/stable/util.cpp
@@ -0,0 +1,65 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/util.h"
9
10int Bu::getDaysInMonth( int iMonth, int iYear )
11{
12 if( iMonth > 11 )
13 {
14 iYear += iMonth/12;
15 iMonth = iMonth%12;
16 }
17 switch( iMonth )
18 {
19 case 0:
20 case 2:
21 case 4:
22 case 6:
23 case 7:
24 case 9:
25 case 11:
26 return 31;
27 break;
28
29 case 3:
30 case 5:
31 case 8:
32 case 10:
33 return 30;
34 break;
35
36 case 1:
37 if( iYear%400 == 0 )
38 return 29;
39 if( iYear%100 == 0 )
40 return 28;
41 if( iYear%4 == 0 )
42 return 29;
43 return 28;
44 break;
45
46 default:
47 return -1;
48 }
49}
50void Bu::memcpy( void *pDest, const void *pSrc, size_t iBytes )
51{
52#ifdef VALTEST
53 const char *src = (const char *)pSrc;
54 char *dest = (char *)pDest;
55 for( int j = 0; j < count; j++ )
56 {
57 *dest = *src;
58 dest++;
59 src++;
60 }
61#else
62 ::memcpy( pDest, pSrc, iBytes );
63#endif
64}
65