⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 daytime.hpp

📁 gps源代码
💻 HPP
📖 第 1 页 / 共 3 页
字号:
          * @return a reference to this object.          */      DayTime& setGPSfullweek(short fullweek,                              long zcount,                               TimeFrame f = Unknown)         throw(DayTimeException)      { return setGPSfullweek(fullweek, double(zcount) * 1.5, f) ; }         /**          * Set the object's time using the given GPSZcount.          * @warn The number of GPS week rollovers, and therefore the          * full GPS week, is determined from the current system time.          * @param z the GPSZcount object to set to          * @param f Time frame (see #TimeFrame)          * @return a reference to this object.          */      DayTime& setGPSZcount(const GPSZcount& z,                            TimeFrame f = Unknown)         throw(DayTimeException);         /**          * Set the object's time using the give CommonTime.          * @param c the CommonTime object to set to          * @param f Time frame (see #TimeFrame))          * @return a reference to this object.          */      DayTime& setCommonTime(const CommonTime& c,                             TimeFrame f = Unknown)         throw();         /**          * Set the object's time using day of year.          * @param year Four-digit year.          * @param day_of_year Day of year.          * @param sec_of_day Seconds of day.          * @param f Time frame (see #TimeFrame)          * @return a reference to this object.          */      DayTime& setYDoySod(short year,                          short day_of_year,                           double sec_of_day,                           TimeFrame f = Unknown)         throw(DayTimeException);         /**          * Set the object's time using (long double) Modified Julian date.          * This just sets the time to the indicated modified Julian date.          * @param mjd date/time to set, in MJD.          * @param f Time frame (see #TimeFrame)          * @return a reference to this object.          */      DayTime& setMJD(long double mjd,                      TimeFrame f = Unknown)         throw(DayTimeException);         /// Same as setMJD      DayTime& setMJDdate(long double mjd,                           TimeFrame f = Unknown)         throw(DayTimeException)       { return setMJD(mjd, f); }         /// Same as setMJD but with input of type double      DayTime& setMJD(double mjd,                       TimeFrame f = Unknown)         throw(DayTimeException)      { return setMJD((long double)(mjd), f) ; }         /// Same as setMJD but with input of type double      DayTime& setMJDdate(double mjd,                           TimeFrame f = Unknown)         throw(DayTimeException)      { return setMJD((long double)(mjd), f) ; }         /**          * Set the object's time using POSIX structures.          * This uses the POSIX timeval struct to set the time.  This          * structure represents the time with a resolution of          * microseconds.          * @param t time to set          * @param f Time frame (see #TimeFrame)          * @return a reference to this object.          */      DayTime& setUnix(const struct timeval& t,                        TimeFrame f = Unknown)         throw(DayTimeException);         /**          * Set the object's time using ANSI structures.  This uses          * the ANSI C/C++ time_t struct to set the time.  This          * structure represents the time with a resolution of          * seconds.          * @param t time to set          * @param f Time frame (see #TimeFrame)          * @return a reference to this object.          */      DayTime& setANSI(const time_t& t,                       TimeFrame f = Unknown)         throw(DayTimeException);         /**          * Set the object's time to the current system time.          * If the POSIX gettimeofday() system call is available, it          * is used to determine system time.  If the gettimeofday()          * call is not available, the ANSI time() system call is used          * to determine system time.          * @return a reference to this object.          */      DayTime& setSystemTime()         throw(DayTimeException);         /**          * Set the object time to the current local time.          */      DayTime& setLocalTime()         throw(DayTimeException);         /**          * Set the object using calendar (Y/M/D) date only (time is unchanged)          * @param yy four-digit year.          * @param mm month of year (1-based).          * @param dd day of month (1-based).          * @param f Time frame (see #TimeFrame)          * @return a reference to this object.          */      DayTime& setYMD(int yy,                      int mm,                      int dd,                      TimeFrame f = Unknown)         throw(DayTimeException);         /**          * Set the object using ordinary (H:M:S) time only (day is unchanged)          * @param hh hour of day.          * @param mm minutes of hour.          * @param sec seconds of minute.          * @param f Time frame (see #TimeFrame)          * @return a reference to this object.          */      DayTime& setHMS(int hh,                      int mm,                      double sec,                       TimeFrame f = Unknown)         throw(DayTimeException);         /**          * Set the object using seconds of day only (day is unchanged)          * @param sod seconds of day.          */      DayTime& setSecOfDay(double sod,                           TimeFrame f = Unknown)         throw(DayTimeException);         /**          * Set the object using year and day of year only (time is unchanged)          * @param sod seconds of day.          */      DayTime& setYDoy(int yy,                       int doy,                       TimeFrame f = Unknown)         throw(DayTimeException);         // ----------- Part 10: member functions: setToString, printf --------         //         // FIX someone figure out how to make the table below show up         // nice in doxygen.         /**          * Similar to scanf, this function takes a string and a          * format describing string in order to read in daytime          * values.  The parameters it can take are listed below and          * described above with the printf() function.          *          * The specification must resolve to a day at a minimum          * level. The following table lists combinations that give valid          * times. Anything more or other combinations will give          * unknown (read as: "bad") results so don't try it.  Anything          * less will throw an exception.  If nothing changes the time          * of day, it will default to midnight.  Also, the year          * defaults to the current year if a year isn't specified          * or can't be determined.          *          * @code          *  1 of...           and 1 of....         optional...          *  %C          *  %G                %w %g %Z                %Y %y          *  %F                %w %g %Z          *  %m %B %b          %a %A %d             %Y %y %H %M %S          *  %Q          *  %j                                      %Y %y %s          * @endcode          *          * So           * @code          * time.setToString("Aug 1, 2000 20:20:20", "%b %d, %Y %H:%M:%S")          * @endcode          * works but           * @code          * time.setToString("Aug 2000", "%b %Y")          * @endcode          * doesn't work (incomplete specification because it doesn't specify          * a day).          *          * Don't worry about counting whitespace - this function will          * take care of that.  Just make sure that the extra stuff in          * the format string (ie '.' ',') are in the same relative          * location as they are in the actual string.  (see in the          * example above))          *          * @param str string to get date/time from.          * @param fmt format to use to parse \c str.          * @throw DayTimeException if \c fmt is an incomplete specification          * @throw FormatException if unable to scan \c str.          * @throw StringException if an error occurs manipulating the          * \c str or \c fmt strings.          * @return a reference to this object.          */      DayTime& setToString(const std::string& str,                            const std::string& fmt)         throw(DayTimeException, FormatException,               gpstk::StringUtils::StringException);         // if you can see this, ignore the \'s below, as they are for         // the nasty html-ifying of doxygen.  Browsers try and         // interpret the % and they get all messed up.         /**          * Format this time into a string.          *          * Generate and return a string containing a formatted          * date, formatted by the specification \c fmt.          *          * \li \%Y   year()          * \li \%y   year() % 100          * \li \%m   month()          * \li \%d   day()          * \li \%H   hour()          * \li \%M   minute()          * \li \%S   (short)second()          * \li \%f   second()          * \li \%G   GPS10bitweek()          * \li \%F   GPSfullweek()          * \li \%g   GPSsecond() or GPSsow()          * \li \%s   DOYsecond()          * \li \%Q   MJDdate()          * \li \%w   dayOfWeek() or GPSday()          * \li \%b   MonthAbbrevName[month()]          * \li \%B   MonthName[month()]          * \li \%a   DayOfWeekAbbrevName[dayOfWeek()]          * \li \%A   DayOfWeekName[dayOfWeek()]          * \li \%j   DOYday() or DOY()          * \li \%Z   GPSzcount()          * \li \%z   GPSzcountFloor()          * \li \%U   unixTime().tv_sec          * \li \%u   unixTime().tv_usec          * \li \%C   fullZcount()          * \li \%c   fullZcountFloor()          *          * @param fmt format to use for this time.          * @return a string containing this time in the          * representation specified by \c fmt.          */      std::string printf(const char *fmt) const         throw(gpstk::StringUtils::StringException);         /// Format this time into a string. @see printf(const char*)      std::string printf(const std::string& fmt) const         throw(gpstk::StringUtils::StringException)       { return printf(fmt.c_str()) ; }         /// Returns the string that operator<<() would print.      std::string asString() const         throw(gpstk::StringUtils::StringException);         /// Dump everything possible, using every get() TD: keep?      void dump(std::ostream& s) const         throw(DayTimeException);         // ----------- Part 11: functions: fundamental conversions ----------         //          /** Fundamental routine to convert from "Julian day" (= JD + 0.5)           *  to calendar day.          * @param jd long integer "Julian day" = JD+0.5          * @param iyear reference to integer year          * @param imonth reference to integer month (January == 1)          * @param iday reference to integer day of month           *  (1st day of month == 1)          * @note range of applicability of this routine is from 0JD (4713BC)          *  to approx 3442448JD (4713AD).          * Algorithm references: Sinnott, R. W. "Bits and Bytes,"          *  Sky & Telescope Magazine, Vol 82, p. 183, August 1991, and          *  The Astronomical Almanac, published by the U.S. Naval Observatory.          */      static void convertJDtoCalendar(long jd,                                       int& iyear,                                       int& imonth,                                       int& iday)         throw();         /** Fundamental routine to convert from calendar day to "Julian day"          *  (= JD + 0.5)          * @param iyear reference to integer year          * @param imonth reference to integer month (January == 1)          * @param iday reference to integer day of month           *  (1st day of month == 1)          * @return jd long integer "Julian day" = JD+0.5          * @note range of applicability of this routine is from 0JD (4713BC)          * to approx 3442448JD (4713AD).          * Algorithm references: Sinnott, R. W. "Bits and Bytes,"          *  Sky & Telescope Magazine, Vol 82, p. 183, August 1991, and          *  The Astronomical Almanac, published by the U.S. Naval Observatory.          */      static long convertCalendarToJD(int iyear,                                       int imonth,                                      int iday)          throw();         /** Fundamental routine to convert seconds of day to H:M:S          * @param sod seconds of day (input)          * @param hh reference to integer hour (0 <= hh < 24) (output)          * @param mm reference to integer minutes (0 <= mm < 60) (output)          * @param sec reference to double seconds (0 <= sec < 60.0) (output)          */      static void convertSODtoTime(double sod,                                   int& hh,                                    int& mm,                                    double& sec)          throw();         /** Fundamental routine to convert H:M:S to seconds of day          * @param hh integer hour (0 <= hh < 24) (input)          * @param mm integer minutes (0 <= mm < 60) (input)          * @param sec double seconds (0 <= sec < 60.0) (input)          * @return sod seconds of day (input)          */      static double convertTimeToSOD(int hh,                                     int mm,                                      double sec)          throw();         // ----------- Part 12: private functions and member data ----------         //   private:         /// Initialization method.  Used by the constructors.      void init()          throw();         /// Constructor with direct member data input.      DayTime(long jd,              long sod,              double ms,              double tol,               TimeFrame f = Unknown)         throw()             : jday(jd), mSod(sod), mSec(ms), tolerance(tol), timeFrame(f)       {}         /** Helper routine for add...() functions          * @param ldd the number of days to add to jday          * @param lds the number of milliseconds to add to mSod          * @param ds the number of partial milliseconds to add to mSec          * @throws DayTimeException if adding these values causes an overflow          *  of the jday value          */      void addLongDeltaTime(long ldd,                            long lds,                             double ds)         throw(DayTimeException);                  /// Helper routine to realign the internal representation in order to         /// avoid incorrect output (printf) when mSec is within tolerance of 1      void realignInternals(void)         throw();         /// integer 'Julian day', = JD+0.5 (0 <= jday <= 3442448)      long jday;                    /// integer milliseconds of the day (0 <= mSod <= 86400000)      long mSod;                    /// double fractional milliseconds (mSec < 1.0)      double mSec;                  /// double tolerance used in comparisons (seconds)      double tolerance;             /// @sa TimeFrame      TimeFrame timeFrame;    };   // end class DayTime      // ----------- Part 13: operator<< -----------      //      /**       * Stream output for DayTime objects.  Typically used for debugging.       * @param s stream to append formatted DayTime to.       * @param t DayTime to append to stream \c s.       * @return reference to \c s.       */   std::ostream& operator<<( std::ostream& s,                             const gpstk::DayTime& t );      //@}}  // namespace gpstk#endif   // GPSTK_DAYTIME_HPP

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -