1 /***************************************************************************
2 kstarsdatetime.h - K Desktop Planetarium
4 begin : Tue 05 May 2004
5 copyright : (C) 2001 by Jason Harris
6 email : jharris@30doradus.org
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
18 #ifndef KSTARSDATETIME_H
19 #define KSTARSDATETIME_H
21 #define J2000 2451545.0 //Julian Date for noon on Jan 1, 2000 (epoch J2000)
22 //defined here because this file is included in every other class.
23 #define B1950 2433282.4235 // Julian date for Jan 0.9235, 1950
24 #define SIDEREALSECOND 1.002737909 //number of sidereal seconds in one solar second
26 #include "libkdeedu/extdate/extdatetime.h"
30 /**@class KStarsDateTime
31 *@short Extension of ExtDateTime for KStars
36 class KStarsDateTime
: public ExtDateTime
40 KStarsDateTime( long int jd
);
41 KStarsDateTime( const KStarsDateTime
&kdt
);
42 KStarsDateTime( const ExtDateTime
&kdt
);
43 KStarsDateTime( const ExtDate
&_d
, const QTime
&_t
);
44 KStarsDateTime( double djd
);
45 KStarsDateTime( long double djd
);
47 void setDJD( long double jd
);
48 void setDate( const ExtDate
&d
);
49 void setTime( const QTime
&t
);
51 KStarsDateTime
addSecs( long double s
) const { return KStarsDateTime( djd() + s
/86400. ); }
52 KStarsDateTime
addDays( int nd
) const { return KStarsDateTime( djd() + (long double)nd
); }
54 bool operator == ( const KStarsDateTime
&d
) const { return DJD
== d
.djd(); }
55 bool operator != ( const KStarsDateTime
&d
) const { return DJD
!= d
.djd(); }
56 bool operator < ( const KStarsDateTime
&d
) const { return DJD
< d
.djd(); }
57 bool operator <= ( const KStarsDateTime
&d
) const { return DJD
<= d
.djd(); }
58 bool operator > ( const KStarsDateTime
&d
) const { return DJD
> d
.djd(); }
59 bool operator >= ( const KStarsDateTime
&d
) const { return DJD
>= d
.djd(); }
61 /**@return the date and time according to the CPU clock (note that this is not
64 static KStarsDateTime
currentDateTime();
66 /**@return the julian day as a long double, including the time as the fractional portion.
68 long double djd() const { return DJD
; }
70 /**@return the fraction of the Julian Day corresponding to the current time.
72 *Because the integer Julian Day value jd() is referenced to Noon on the current date,
73 *jdFrac() ranges between values of -0.5 and +0.5 for the previous and next midnights,
76 double jdFrac() const { return ((time().hour()-12) + (time().minute()
77 + (time().second() + time().msec()/1000.)/60.)/60.)/24.; }
78 long double JDat0hUT() const { return int( djd() - 0.5 ) + 0.5; }
81 QTime
GSTtoUT( dms GST
) const;
83 double epoch() const { return ( double( date().year() )
84 + double( date().dayOfYear() )/double( date().daysInYear() ) ); }
85 void setFromEpoch( double e
);
87 dms
GSTat0hUT() const;
91 #endif //KSTARSDATETIME_H