diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-03-25 20:00:08 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-03-25 20:00:08 +0000 |
commit | 469bbcf0701e1eb8a6670c23145b0da87357e178 (patch) | |
tree | b5b062a16e46a6c5d3410b4e574cd0cc09057211 /src/stable/util.cpp | |
parent | ee1b79396076edc4e30aefb285fada03bb45e80d (diff) | |
download | libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.gz libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.bz2 libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.xz libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.zip |
Code is all reorganized. We're about ready to release. I should write up a
little explenation of the arrangement.
Diffstat (limited to 'src/stable/util.cpp')
-rw-r--r-- | src/stable/util.cpp | 65 |
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 | |||
10 | int 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 | } | ||
50 | void 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 | |||