libkholidays
lunarphase.h
00001 /* 00002 This file is part of libkholidays. 00003 Copyright (c) 2004 Allen Winter <winter@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU General Public License as 00007 published by the Free Software Foundation; either version 2 of the 00008 License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; if not, write to the Free Software 00017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 00019 In addition, as a special exception, the copyright holders give 00020 permission to link the code of this program with any edition of 00021 the Qt library by Trolltech AS, Norway (or with modified versions 00022 of Qt that use the same license as Qt), and distribute linked 00023 combinations including the two. You must obey the GNU General 00024 Public License in all respects for all of the code used other than 00025 Qt. If you modify this file, you may extend this exception to 00026 your version of the file, but you are not obligated to do so. If 00027 you do not wish to do so, delete this exception statement from 00028 your version. 00029 */ 00030 00031 #ifndef KHOLIDAYS_LUNARPHASE_H 00032 #define KHOLIDAYS_LUNARPHASE_H 00033 00060 #include <qstring.h> 00061 #include <qdatetime.h> 00062 00063 #include <time.h> 00064 00065 class LunarPhase 00066 { 00067 public: 00068 enum Phase { New, FirstQ, LastQ, Full, None }; 00069 enum Hemisphere { Northern, Southern }; 00070 00071 LunarPhase( Hemisphere hemisphere = Northern ); 00072 ~LunarPhase(); 00073 00081 Phase phase( const QDate &date ) const; 00082 00090 QString phaseStr( const QDate &date ) const; 00091 00097 void setHemisphere( Hemisphere hemisphere = Northern ); 00098 00102 Hemisphere hemisphere() const; 00103 00107 QString hemisphereStr() const; 00108 00112 static QString hemisphereName( Hemisphere hemisphere ); 00113 00119 static QString phaseName( Phase phase ); 00120 00121 private: 00129 double percentFull( uint t ) const; 00137 double degreesToRadians( double degree ) const; 00143 void adj360( double *degree ) const; 00144 00145 Hemisphere mHemisphere; 00146 }; 00147 00148 #endif 00149 00150