Ignore:
Timestamp:
Apr 26, 2011, 11:35:40 AM (9 years ago)
Author:
tbretz
Message:
Moved common part of Mjd(), GetUnixTime() into SecondsOfDay(); renamed GetUnixTime to UnixTime() and added RootTime()
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/Time.cc

    r10454 r10460  
    130130}
    131131
     132double_t Time::SecondsOfDay() const
     133{
     134    const time_duration tod = time_of_day();
     135
     136    const int exp = tod.num_fractional_digits();
     137
     138    const double frac = tod.fractional_seconds()/pow(10, exp);
     139    const double sec  = tod.total_seconds()+frac;
     140
     141    return sec;
     142}
     143
    132144// --------------------------------------------------------------------------
    133145//
     
    141153double Time::Mjd() const
    142154{
    143     const time_duration tod = time_of_day();
    144 
    145     const int exp = tod.num_fractional_digits();
    146 
    147     const double frac = tod.fractional_seconds()/pow(10, exp);
    148     const double sec  = tod.total_seconds()+frac;
    149 
    150     return date().modjulian_day()+sec/(24*60*60);
     155    return date().modjulian_day()+SecondsOfDay()/(24*60*60);
    151156
    152157    /*
     
    161166// Return seconds since 1970/1/1
    162167//
    163 time_t Time::GetUnixTime() const
    164 {
    165     const time_duration unx = *this - ptime(fUnixOffset);
    166     return unx.total_seconds();
     168double Time::UnixTime() const
     169{
     170    return (date().modjulian_day()-40587)*24*60*60 + SecondsOfDay();
     171}
     172
     173double Time::RootTime() const
     174{
     175    return (date().modjulian_day()-49718)*24*60*60 + SecondsOfDay();
    167176}
    168177
Note: See TracChangeset for help on using the changeset viewer.