Changeset 10252


Ignore:
Timestamp:
Mar 23, 2011, 10:47:22 AM (9 years ago)
Author:
tbretz
Message:
Added new manipulators with out the fractional part of the seconds and fixed setting of MJD.
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

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

    r10183 r10252  
    3535
    3636// strftime
    37 const _time_format Time::reset = 0;
    38 const _time_format Time::def   = "%c";
    39 const _time_format Time::std   = "%x %X%F";
    40 const _time_format Time::sql   = "%Y-%m-%d %H:%M:%S.%f";
    41 const _time_format Time::iso   = "%Y%m%dT%H%M%S%F%q";
    42 const _time_format Time::magic = "%Y %m %d %H %M %S %f";
     37const _time_format Time::reset  = 0;
     38const _time_format Time::def    = "%c";
     39const _time_format Time::std    = "%x %X%F";
     40const _time_format Time::sql    = "%Y-%m-%d %H:%M:%S.%f";
     41const _time_format Time::ssql   = "%Y-%m-%d %H:%M:%S";
     42const _time_format Time::iso    = "%Y%m%dT%H%M%S%F%q";
     43const _time_format Time::magic  = "%Y %m %d %H %M %S %f";
     44const _time_format Time::smagic = "%Y %m %d %H %M %S";
    4345
    4446/*
     
    118120void Time::Mjd(double mjd)
    119121{
     122    // Convert MJD to seconds since offset
    120123    mjd -= 40587;
    121124    mjd *= 24*60*60;
     
    141144
    142145    const int exp = tod.num_fractional_digits();
    143     const double sec = tod.fractional_seconds()/pow(10, exp);
     146
     147    const double frac = tod.fractional_seconds()/pow(10, exp);
     148    const double sec  = tod.total_seconds()+frac;
    144149
    145150    return date().modjulian_day()+sec/(24*60*60);
  • trunk/FACT++/src/Time.h

    r10183 r10252  
    3636    static const _time_format fmt(const char *txt=0);
    3737
    38     static const _time_format reset; /// Remove the format description from the stream
    39     static const _time_format def;   /// set to format to the locale default
    40     static const _time_format std;   /// set to format to the iso standard
    41     static const _time_format sql;   /// set to format to the sql format
    42     static const _time_format iso;   /// set to format to the extended iso standard
    43     static const _time_format magic; /// set to format to the MAGIC report format
     38    static const _time_format reset;   /// Remove the format description from the stream
     39    static const _time_format def;     /// set to format to the locale default
     40    static const _time_format std;     /// set to format to the iso standard
     41    static const _time_format sql;     /// set to format to the sql format
     42    static const _time_format ssql;    /// set to format to the sql format (without the fraction of seconds)
     43    static const _time_format iso;     /// set to format to the extended iso standard
     44    static const _time_format magic;   /// set to format to the MAGIC report format
     45    static const _time_format smagic;  /// set to format to the MAGIC report format (without the fraction of seconds)
    4446
    4547    /// Enum used in the instantisation of the class to change the inititalisation value
     
    6567
    6668    // Convesion from and to a string
    67     std::string GetAsStr(const char *fmt="%Y-%m-%d %H:%M:%S.%f") const;
    68     void SetFromStr(const std::string &str, const char *fmt="%Y-%m-%d %H:%M:%S.%f");
     69    std::string GetAsStr(const char *fmt="%Y-%m-%d %H:%M:%S") const;
     70    void SetFromStr(const std::string &str, const char *fmt="%Y-%m-%d %H:%M:%S");
    6971
    7072    // Conversion to and from MJD
Note: See TracChangeset for help on using the changeset viewer.