diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2009-08-31 22:40:57 +0000 | 
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2009-08-31 22:40:57 +0000 | 
| commit | 6d6cca7830ed931198cd2df77bafbdd81038171a (patch) | |
| tree | 0ebe21bca4f6a65e78ad9971bdc513c8222e5bfa /src/util.cpp | |
| parent | 6e7f15f8157499796689a2bff1d110e83104ef43 (diff) | |
| download | libbu++-6d6cca7830ed931198cd2df77bafbdd81038171a.tar.gz libbu++-6d6cca7830ed931198cd2df77bafbdd81038171a.tar.bz2 libbu++-6d6cca7830ed931198cd2df77bafbdd81038171a.tar.xz libbu++-6d6cca7830ed931198cd2df77bafbdd81038171a.zip  | |
Added a getDaysInMonth function, it'll live in util.{cpp,h} until I create an
actual Date class.
Diffstat (limited to 'src/util.cpp')
| -rw-r--r-- | src/util.cpp | 40 | 
1 files changed, 40 insertions, 0 deletions
diff --git a/src/util.cpp b/src/util.cpp index 111574c..3ca711d 100644 --- a/src/util.cpp +++ b/src/util.cpp  | |||
| @@ -1 +1,41 @@ | |||
| 1 | #include "bu/util.h" | 1 | #include "bu/util.h" | 
| 2 | |||
| 3 | int Bu::getDaysInMonth( int iMonth, int iYear ) | ||
| 4 | { | ||
| 5 | if( iMonth > 11 ) | ||
| 6 | { | ||
| 7 | iYear += iMonth/12; | ||
| 8 | iMonth = iMonth%12; | ||
| 9 | } | ||
| 10 | switch( iMonth ) | ||
| 11 | { | ||
| 12 | case 0: | ||
| 13 | case 2: | ||
| 14 | case 4: | ||
| 15 | case 6: | ||
| 16 | case 7: | ||
| 17 | case 9: | ||
| 18 | case 11: | ||
| 19 | return 31; | ||
| 20 | break; | ||
| 21 | |||
| 22 | case 3: | ||
| 23 | case 5: | ||
| 24 | case 8: | ||
| 25 | case 10: | ||
| 26 | return 30; | ||
| 27 | break; | ||
| 28 | |||
| 29 | case 1: | ||
| 30 | if( iYear%400 == 0 ) | ||
| 31 | return 29; | ||
| 32 | if( iYear%100 == 0 ) | ||
| 33 | return 28; | ||
| 34 | if( iYear%4 == 0 ) | ||
| 35 | return 29; | ||
| 36 | return 28; | ||
| 37 | break; | ||
| 38 | } | ||
| 39 | |||
| 40 | } | ||
| 41 | |||
