Changeset 10460 for trunk


Ignore:
Timestamp:
04/26/11 11:35:40 (13 years ago)
Author:
tbretz
Message:
Moved common part of Mjd(), GetUnixTime() into SecondsOfDay(); renamed GetUnixTime to UnixTime() and added RootTime()
Location:
trunk/FACT++/src
Files:
2 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
  • trunk/FACT++/src/Time.h

    r10454 r10460  
    9191    unsigned int   us() const { return time_of_day().total_microseconds()%1000000; }
    9292
    93     time_t GetUnixTime() const;
     93    double SecondsOfDay() const;
    9494
     95    double UnixTime() const;
     96    double RootTime() const;
    9597};
    9698
Note: See TracChangeset for help on using the changeset viewer.