![]() |
Main Page
Class Hierarchy
Alphabetical List
Compound List
File List
Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * Julian Date object * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 2003 by Mathew Robertson. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or * 00009 * modify it under the terms of the GNU Lesser General Public * 00010 * License as published by the Free Software Foundation; either * 00011 * version 2.1 of the License, or (at your option) any later version. * 00012 * * 00013 * This library is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00016 * Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public * 00019 * License along with this library; if not, write to the Free Software * 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 00021 ********************************************************************************/ 00022 // Origonal design/implementation taken from jDate by: J. Knight <jimbag@kw.igs.net> 00023 #ifndef FXJULIANDATE_H 00024 #define FXJULIANDATE_H 00025 00026 namespace FXEX { 00027 00028 /** 00029 * Julian date to Gregorian data object 00030 */ 00031 class FXAPI FXJulianDate { 00032 private: 00033 FXuint julian; // the date in Julian date format 00034 static const FXchar *monthNames[]; // names of months 00035 static const FXchar *dayNames[]; // names of days of the week 00036 00037 protected: 00038 FXuint greg2jul( FXint y, FXint m, FXint d ); 00039 void jul2greg( FXuint jd, FXint &y, FXint &m, FXint &d ); 00040 00041 public: 00042 /// use today's date 00043 FXJulianDate(); 00044 00045 /// use specific date 00046 FXJulianDate( FXint yr, FXint mo, FXint da ); 00047 00048 /// set the adte to a specific date 00049 void setDate( FXint y, FXint m, FXint d ); 00050 00051 /// set it to today's date 00052 void today(); 00053 00054 /// accessors 00055 FXint day(); 00056 FXint month(); 00057 FXint year(); 00058 FXint daysInMonth(); 00059 FXint dayOfWeek(); 00060 FXint dayOfYear(); 00061 00062 /// is the value a leap year 00063 FXbool leapYear( FXint y ); 00064 00065 /// get the name of the month 00066 const FXchar *monthName( FXint month ) const; 00067 00068 /// get the name of the day 00069 const FXchar *dayName( FXint day ) const; 00070 00071 /// save to stream 00072 friend FXAPI FXStream& operator<< (FXStream& store,const FXJulianDate& d); 00073 00074 /// load from stream 00075 friend FXAPI FXStream& operator>> (FXStream& store,FXJulianDate& d); 00076 00077 /// dtor 00078 virtual ~FXJulianDate() {} 00079 }; 00080 00081 } // namespace FXEX 00082 #endif // FXJULIANDATE_H