/usr/include/ossim/base/ossimDate.h is in libossim-dev 1.7.21-3ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | //*******************************************************************
//
// License: LGPL
//
// See LICENSE.txt file in the top level directory for more details.
//
// Author: Garrett Potts
//
//*************************************************************************
// $Id: ossimDate.h 14902 2009-07-17 11:26:20Z gpotts $
#ifndef ossimDate_HEADER
#define ossimDate_HEADER
#include <ctime>
#include <iosfwd>
#include <ossim/base/ossimConstants.h>
#include <ossim/base/ossimXmlNode.h>
class OSSIM_DLL ossimLocalTm : public std::tm
{
public:
friend std::ostream& operator<< (std::ostream& out, const ossimLocalTm& src);
friend OSSIM_DLL int operator== (const ossimLocalTm& t1,
const ossimLocalTm& src);
friend OSSIM_DLL int operator!= (const ossimLocalTm& t1,
const ossimLocalTm& src);
friend OSSIM_DLL int operator< (const ossimLocalTm& t1,
const ossimLocalTm& src);
friend OSSIM_DLL int operator<= (const ossimLocalTm& t1,
const ossimLocalTm& src);
friend OSSIM_DLL int operator> (const ossimLocalTm& t1,
const ossimLocalTm& src);
friend OSSIM_DLL int operator>= (const ossimLocalTm& t1,
const ossimLocalTm& src);
ossimLocalTm (time_t t=0); // Set to time, 0 is magic for 'now'
ossimLocalTm (tm const & t); // Copy constructor
ossimLocalTm & operator= (tm const & t); // Assignment
operator time_t (void) const; // Conversion operator
int isValid (void) const; // Test for validity
void now();
int compare (ossimLocalTm const & t) const; // Compare times
int compare (std::time_t const tt) const; // Compare times
enum ossimLocalTmFormat // Date format flags
{
ossimLocalTmFormatYear = (int)0x0001, // Print year
ossimLocalTmFormatYearShort = (int)0x0002, // Print last two digits
ossimLocalTmFormatPadYear = (int)0x0004, // Pad year to 2 or 4
ossimLocalTmFormatZeroYear = (int)0x0008, // Zero fill year
ossimLocalTmFormatMonth = (int)0x0010, // Print month
ossimLocalTmFormatMonText = (int)0x0020, // Print month in text
ossimLocalTmFormatPadMon = (int)0x0040, // Pad to 2 (trunc to 3)
ossimLocalTmFormatZeroMon = (int)0x0080, // Zero fill month
ossimLocalTmFormatDay = (int)0x0100, // Print date
ossimLocalTmFormatDayOfWeek = (int)0x0200, // Print day of week
ossimLocalTmFormatPadDay = (int)0x0400, // Pad date to 2
ossimLocalTmFormatZeroDay = (int)0x0800, // Zero fill day
ossimLocalTmFormatDMY = (int)0x0111, // Print date, mth, year
ossimLocalTmFormatPadDMY = (int)0x0444, // Pad all three
ossimLocalTmFormatZeroDMY = (int)0x0888, // Zero fill all three
ossimLocalTmFormatYearFirst = (int)0x1000, // Print year first
ossimLocalTmFormatMonFirst = (int)0x2000, // Print month first
ossimLocalTmFormatSepChar = (int)0x4000,// Separate fields datech
ossimLocalTmFormatSepSpace = (int)0x8000, // Separate fields space
ossimLocalTmFormatInternational = (int)(ossimLocalTmFormatDMY|ossimLocalTmFormatMonText|ossimLocalTmFormatPadMon|
ossimLocalTmFormatSepSpace),
ossimLocalTmFormatIntlShort = (int)(ossimLocalTmFormatDMY|ossimLocalTmFormatMonText|ossimLocalTmFormatPadMon|
ossimLocalTmFormatSepSpace|ossimLocalTmFormatYearShort),
ossimLocalTmFormatUsa = (int)(ossimLocalTmFormatDMY|ossimLocalTmFormatMonFirst|ossimLocalTmFormatPadDMY|
ossimLocalTmFormatZeroDMY|ossimLocalTmFormatYearShort|ossimLocalTmFormatSepChar),
ossimLocalTmFormatEnglish = (int)(ossimLocalTmFormatDMY|ossimLocalTmFormatYearShort|ossimLocalTmFormatPadDMY|
ossimLocalTmFormatZeroDMY|ossimLocalTmFormatSepChar),
ossimLocalTmFormatJapanese = (int)(ossimLocalTmFormatDMY|ossimLocalTmFormatYearFirst|ossimLocalTmFormatPadDMY|
ossimLocalTmFormatZeroDMY|ossimLocalTmFormatYearShort|ossimLocalTmFormatMonFirst|
ossimLocalTmFormatSepChar),
ossimLocalTmFormatFull = (int)(ossimLocalTmFormatDMY|ossimLocalTmFormatDayOfWeek|ossimLocalTmFormatMonText|
ossimLocalTmFormatSepSpace)
};
enum ossimTimeFormat // Time format (nb: time zones not implemented)
{
ossimTimeFormatSecs = (int)0x0001, // Print seconds
ossimTimeFormatZeroSecs = (int)0x0002, // Zero fill seconds
ossimTimeFormatPadSecs = (int)0x0004, // Pad seconds to 2
ossimTimeFormatSecsAll = (int)0x0007,
ossimTimeFormatTimeZone = (int)0x0008, // Print timezone
ossimTimeFormatMins = (int)0x0010, // Print minutes
ossimTimeFormatZeroMins = (int)0x0020, // Zero fill minutes
ossimTimeFormatPadMins = (int)0x0040, // Pad minutes to 2
ossimTimeFormatMinsAll = (int)0x0070,
ossimTimeFormatTZNumeric = (int)0x0080, // Print numeric TZ
ossimTimeFormatHour = (int)0x0100, // Print hour
ossimTimeFormatZeroHour = (int)0x0200, // Zero fill hour
ossimTimeFormatPadHour = (int)0x0400, // Pad hour to 2 digits
ossimTimeFormatHourAll = (int)0x0700,
ossimTimeFormat24hour = (int)0x0800, // 24hour clock
ossimTimeFormatSepChar = (int)0x1000, // Separate field timech
ossimTimeFormatSepSpace = (int)0x2000, // Separate fields space
ossimTimeFormatSepAbbrev = (int)0x4000, // Add abbreviations
ossimTimeFormatAmPm = (int)0x8000, // Add 'am' or 'pm'
ossimTimeFormatInternational = (int)(ossimTimeFormatHourAll|ossimTimeFormatMinsAll|ossimTimeFormatSecsAll|
ossimTimeFormat24hour|ossimTimeFormatSepChar),
ossimTimeFormatShortTime = (int)(ossimTimeFormatHourAll|ossimTimeFormatMinsAll|ossimTimeFormat24hour|
ossimTimeFormatSepChar),
ossimTimeFormatClockTime = (int)(ossimTimeFormatHour|ossimTimeFormatPadHour|ossimTimeFormatMinsAll|
ossimTimeFormatAmPm|ossimTimeFormatSepChar),
ossimTimeFormatLongTime = (int)(ossimTimeFormatHour|ossimTimeFormatPadHour|ossimTimeFormatMinsAll|
ossimTimeFormatSecsAll|ossimTimeFormatSepAbbrev|ossimTimeFormatSepSpace),
ossimTimeFormatMillitary = (int)(ossimTimeFormatHourAll|ossimTimeFormatMinsAll|ossimTimeFormat24hour)
};
static char timech; // Character used for time separator
static char datech; // Character used for date separator
static int datefmt; // Default date format
static int timefmt; // Default time format
// Output methods
std::ostream& print(std::ostream & os,
int df =datefmt,
int tf =timefmt) const;
std::ostream& printTime(std::ostream & os, int f =timefmt) const;
std::ostream& printDate(std::ostream & os, int f =datefmt) const;
/**
* @brief method to dump all the data members. This is the tm struct +
* the theFractionalSecond from this class.
*
* @note: tm_gmtoff and tm_zone from tm struct are not printed as they
* are not standard.
*
* @param os Stream to dump to.
*
* @return stream.
*/
std::ostream& dump(std::ostream& os) const;
int getYear()const;
int getShortYear()const;
/*!
* This is one based i.e. values are returned between 1-12
*/
int getMonth()const;
/*!
* returns the day 1-31
*/
int getDay()const;
double getJulian()const;
double getModifiedJulian()const;
ossimLocalTm& setDay(int day);
/*!
* The month is a number bewteen 1 and 12. We will shift it to the internal
* representation
*/
ossimLocalTm& setMonth(int month);
ossimLocalTm& setYear(int year);
ossimLocalTm& setDateFromJulian(double jd);
ossimLocalTm& setDateFromModifiedJulian(double mjd);
void setFractionalDay(double fractionalDay);
static void extractHmsFromFractionalDay(double fractionalDay,
int &h,
int &m,
int &s,
double& fractionalSecond);
int getHour()const;
int getMin()const;
int getSec()const;
double getFractionalSecond()const;
ossimLocalTm& setHour(int h);
ossimLocalTm& setMin(int m);
ossimLocalTm& setSec(int s);
ossimLocalTm& setFloatSec(double s);
ossimLocalTm& setFractionalSecond(double fractS);
/**
* getTicks() will call getEpoc. This is te number of microseconds passed
* since (00:00:00 UTC, January 1, 1970)
*/
time_t getTicks()const;
time_t getEpoc()const;
void addSeconds(ossim_float64 n);
void addMinutes(ossim_float64 n);
void addHours(ossim_float64 n);
void addDays(ossim_float64 n);
ossim_float64 deltaInSeconds(const ossimLocalTm& d)const;
ossim_float64 deltaInMinutes(const ossimLocalTm& d)const;
ossim_float64 delatInHours(const ossimLocalTm& d)const;
ossim_float64 deltaInDays(const ossimLocalTm& d)const;
ossimLocalTm convertToGmt()const;
/**
* Will not adjust for timezone. The passed in value is based on seconds.
*/
void setTimeNoAdjustmentGivenEpoc(time_t ticks);
/**
* Will adjust for timezone. The passed in value is based on seconds.
*/
void setTimeGivenEpoc(time_t ticks);
bool setIso8601(const std::string& timeString, bool shiftToGmtOffsetZero=false);
ossimRefPtr<ossimXmlNode> saveXml()const;
bool loadXml(ossimRefPtr<ossimXmlNode> dateNode);
protected:
// Time suffix
void tSfx(std::ostream & os, int fmt, char ch) const;
// Time field formatters
void pHour(std::ostream & os, int fmt) const;
void pMins(std::ostream & os, int fmt) const;
void pSecs(std::ostream & os, int fmt) const;
// Date suffix
void dSfx(std::ostream & os, int fmt) const;
// Date field formatters
void pDate(std::ostream & os, int fmt) const;
void pMonth(std::ostream & os, int fmt) const;
void pYear(std::ostream & os, int fmt) const;
double theFractionalSecond;
};
class OSSIM_DLL ossimDate : public ossimLocalTm
{
public:
friend std::ostream& operator<<(std::ostream& out, const ossimDate& src);
ossimDate(int datefmt =ossimLocalTm::datefmt);
ossimDate (ossimLocalTm const & t,
int dtfmt =ossimLocalTm::datefmt);
ossimDate (time_t t, int dtfmt =ossimLocalTm::datefmt);
ossimDate(int month, int day, int year,int dtfmt=ossimLocalTm::datefmt);
int fmt(int f);
int fmt(void) const;
std::ostream & print (std::ostream & os) const;
private:
int _fmt;
};
class OSSIM_DLL ossimTime :public ossimLocalTm
{
public:
friend std::ostream& operator <<(std::ostream& out, const ossimTime& src);
ossimTime(int tmfmt =ossimLocalTm::timefmt);
ossimTime (ossimTime const & t,
int tmfmt =ossimLocalTm::timefmt);
ossimTime (time_t t, int tmfmt =ossimLocalTm::timefmt);
int fmt (int f);
int fmt (void) const;
std::ostream& print (std::ostream & os) const;
private:
int _fmt;
};
#endif
|