/usr/include/casacore/casa/OS/Time.h is in casacore-dev 2.2.0-2.
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 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 | //# Time.h: enquiry functions for calendar and clock time, with some operations
//# Copyright (C) 1994,1995,1999,2000,2001
//# Associated Universities, Inc. Washington DC, USA.
//#
//# This library is free software; you can redistribute it and/or modify it
//# under the terms of the GNU Library General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or (at your
//# option) any later version.
//#
//# This library is distributed in the hope that it will be useful, but WITHOUT
//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
//# License for more details.
//#
//# You should have received a copy of the GNU Library General Public License
//# along with this library; if not, write to the Free Software Foundation,
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
//#
//# Correspondence concerning AIPS++ should be addressed as follows:
//# Internet email: aips2-request@nrao.edu.
//# Postal address: AIPS++ Project Office
//# National Radio Astronomy Observatory
//# 520 Edgemont Road
//# Charlottesville, VA 22903-2475 USA
//#
//# $Id$
#ifndef CASA_TIME_H
#define CASA_TIME_H
#include <casacore/casa/aips.h>
#include <casacore/casa/BasicSL/String.h>
#include <casacore/casa/iosfwd.h>
namespace casacore { //# NAMESPACE CASACORE - BEGIN
// <Summary> date and time enquiry functions, with some operations.
// </summary>
//
// <use visibility=export>
//
// <reviewed reviewer="Paul Shannon" date="1995/03/01" tests="tTime" demos="">
// This class might be better named a Date object, especially given that
// more accurate Time classes are going to be required.
// </reviewed>
// <prerequisite>
// <li> you should understand the difference between "Julian" and
// "modified Julian" date
// </prerequisite>
// <synopsis>
// This class provides convenient date objects for the programmer.
// Once constructed, they may be compared, read and written, and
// queried for a wide variety of re-expressions. In a typical (?) use
// you might create a Time object, and then query it to find out
// the current month, day of the week, and whether it is a leap
// year. You can also find out the number of seconds which have elapsed
// since a specific Time.
//
// <note role=caution> This class should not be used for very high precision
// work. The time from epoch (1970.0) in seconds is
// interconverted between computer "double" values, and
// some loss of accuracy might result.
// </note>
// </synopsis>
// <example>
// <srcblock>
// Time startTime;
// Time moonLanding (1969,7,14);
// cout << "date and time of moon landing: " << moonLanding << endl;
// cout << "day of week: " << moonLanding.dayOfWeek () << endl;
// cout << "day of year: " << moonLanding.dayOfYear () << endl;
// cout << "seconds since moon landing: " << moonLanding.age () << endl;
// cout << "weeks since moon landing: " <<
// moonLanding.age () / (60 * 60 * 24 * 7) << endl;
// cout << "seconds elapsed since start: " << startTime.age () << endl;
// </srcblock>
// </example>
//
// <todo asof="1995/03/23">
// <li> member function 'age' might be renamed 'elapsedTime'
// <li> A reference to the source of each algorithm should be provided.
// </todo>
class Time {
public:
// the default constructor returns an object with the present date and time
Time ();
// Construct time with Julian day number
Time (double jdn);
// Construct Time with Gregorian calendar
// <ul>
// <li> seconds after the minute [0,59.999] (include milliseconds)
// <li> minutes after the hour [0,59]
// <li> hours after midnight [0,23]
// <li> day of the month [1,31]
// <li> month of the year [1,12]
// <li> year. Beware, because '94' refers to the early Christian era, not
// the 20th century.
// </ul>
Time (uInt year, uInt month, uInt day, uInt hour=0, uInt min=0,
double sec=0.0);
// Copy constructor
Time (const Time& time);
// return the Julian day (unit day)
double julianDay () const;
// return the modified Julian day (unit day)
double modifiedJulianDay () const;
// initialise the julian day data with Time class
Time& operator = (const Time& time);
double operator - (const Time& begin);
Time operator + (const double plus);
Bool operator == (const Time& other) const;
Bool operator != (const Time& other) const;
Bool operator > (const Time& other) const;
Bool operator < (const Time& other) const;
// if iso is True, then use ISO 8601 format
// otherwise, produce the string of the form
// Tue Mar 22 16:40:24 1994
// with GMT time
String toString(const Bool iso=False) const;
// returns a String in ISO 8601 format YYYY-MM-DDTHH:MM:SS in GMT
// note: for dates beyond year 9999, use more digits for year
const String ISODate() const
{ return toString(True); }
// write the current time, GMT, in format
// Tue Mar 22 16:40:24 1994
friend ostream& operator<<(ostream& out, const Time& other)
{
out << other.toString(False);
return out;
}
// read in date, which must be in the following format
// month/day/year,hour:min:sec
// where month,day,year,hour,min and sec are uInt.
friend istream& operator >> (istream&, Time&);
// reset date to the present instant
void now ();
void setDate (uInt year, uInt month, uInt day, uInt hour=0, uInt min=0,
double sec=0.0);
// number of seconds which have elapsed since Time object was created
// or reset
double age ();
// Return the seconds, minutes or hour part of the time.
// <group>
uInt seconds ();
double dseconds ();
uInt minutes ();
uInt hours ();
// </group>
uInt dayOfMonth ();
uInt month ();
uInt year ();
uInt dayOfWeek ();
uInt dayOfYear ();
static uInt howManyDaysInMonth ();
static uInt howManyDaysInMonth (uInt month,uInt year);
static Bool isLeapYear ();
static Bool isLeapYear (uInt year);
// Returns the difference, in seconds, between UTC and local time.
// Negative values are west of GMT, positive are east.
static Int timeZoneSeconds ();
// Same as timeZoneSeconds(), but returns fractional days rather
// than seconds.
static Double timeZoneDays ();
// Returns a string, e.g. "EST" or "MDT", describing the current
// local time zone.
static String timeZoneName ();
protected:
// Modified Julian day number
// 40587 modified Julian day number = 00:00:00 January 1, 1970, GMT.
uInt mJulianDay;
// the fraction of the day
double mJulianDayfrac;
};
} //# NAMESPACE CASACORE - END
#endif
//# roel's original comments -- these may be useful in creating demo
//# programs when we get some time...
//# The function now () updated datas with the present time.
//
//# When create a object. The mJulianDay and mJulianDayfrac datas are
//# initialise with actual modified Julian day. (<now() function).
//# The default constructor is at preset time.
//#
//# i.e. 40587 modified Julian day number = 00:00:00 January 1, 1970, GMT.
//# and 2440587.5 Julian day number = 00:00:00 January 1, 1970, GMT,
//# then modified Julian day number = Julian day number - 2400000.5
//#
//# Important :We are consindered GMT time for all functions.
//# We are considered only dates after 2400000 Julian day = 12:00:00
//# November 15, 1858, GMT.
//#
//# When execute the now() function the actual mJulianDay and
//# mJulianDayFrac datas are replace for the new modified Julian day
//# and the fraction of the day.
//#
//# The function is invoked looks as follows
//#
//# <code>
//#
//# Time t; // The default constructor is at present time (now())
//#
//# t.now();
//#
//# </code>
//#
//# When execute the setDate() function the actual mJulianDay and
//# mJulianDayFrac datas are replace for the new date
//#
//# The function is invoked looks as follows
//#
//# <code>
//#
//# Time t; // The default constructor is at present time (now())
//#
//# t.setDate(1915,2,21);
//#
//# </code>
//#
//# The function age() return the time in seconds between
//# some Time object and now.
//#
//# The function is invoked looks as follows
//#
//# <code>
//#
//# Time t; // The default constructor is at present time (now())
//#
//# cout<<"time since x "<< t.age() <<"\n";
//#
//# </code>
//#
//# The function julianDay() return the julian day number.
//#
//# The function is invoked looks as follows
//#
//# <code>
//#
//# Time t;
//#
//# cout<<"Julian day number "<<t.julianDay()<<"\n";
//#
//# </code>
//#
//# The function modifiedJulianDay() return the modified julian day number.
//#
//# The function is invoked looks as follows
//#
//# <code>
//#
//# Time t;
//#
//# cout<<"Modified Julian day number "<<t.modifiedJulianDay()<<"\n";
//#
//# </code>
//#
//# The function dayOfMonth() return day of the month [1,31]
//# Note: This function doesn't modified the actual datas (mJulianDay and '
//# mJulianDayFrac).
//#
//# The function is invoked looks as follows
//#
//# <code>
//#
//# Time t;
//#
//#
//# cout<<"day of month "<< t.dayOfMonth() <<"\n";
//#
//# </code>
//#
//# The function month() return month of the year [1,12]
//# Note: This function doesn't modified the actual datas (mJulianDay and '
//# mJulianDayFrac).
//#
//# The function is invoked looks as follows
//#
//# <code>
//#
//# Time t;
//#
//#
//# cout<<"month "<< t.month() <<"\n";
//#
//# </code>
//#
//# The function year() return the year.
//# Note: This function doesn't modified the actual datas (mJulianDay and '
//# mJulianDayFrac).
//#
//# The function is invoked looks as follows
//#
//# <code>
//#
//# Time t;
//#
//#
//# cout<<"Year "<< t.year() <<"\n";
//#
//# </code>
//#
//# The function dayOfWeek() return days since sunday [1,7].
//# Note: This function doesn't modified the actual datas (mJulianDay and '
//# mJulianDayFrac).
//#
//# The function is invoked looks as follows
//#
//# <code>
//#
//# Time t;
//#
//#
//# cout<<"day of week "<< t.dayOfWeek() <<"\n";
//#
//# </code>
//#
//# The function dayOfYear() return day of the year [1,366]
//# Note: This function doesn't modified the actual datas (mJulianDay and '
//# mJulianDayFrac).
//#
//# The function is invoked looks as follows
//#
//# <code>
//#
//# Time t;
//#
//#
//# cout<<"day of year "<< t.dayOfYear() <<"\n";
//#
//# </code>
//#
//# The function leapSeconds() return leap seconds.
//# We have the next datas
//#
//# -Note: leapSeconds() removed 1997.10.07 by Jeff Uphoff, after
//# -recommendation by Wim Brouw.
//#
//# leapsec=10;
//#
//# if(modified Julian Day>=41499) leapsec++; // 1 July 1972
//# if(modified Julian Day>=41683) leapsec++; // 1 January 1973
//# if(modified Julian Day>=42048) leapsec++; // 1 January 1974
//# if(modified Julian Day>=42413) leapsec++; // 1 January 1975
//# if(modified Julian Day>=42778) leapsec++; // 1 January 1976
//# if(modified Julian Day>=43144) leapsec++; // 1 January 1977
//# if(modified Julian Day>=43509) leapsec++; // 1 January 1978
//# if(modified Julian Day>=43874) leapsec++; // 1 January 1979
//# if(modified Julian Day>=44239) leapsec++; // 1 January 1980
//# if(modified Julian Day>=44786) leapsec++; // 1 July 1981
//# if(modified Julian Day>=45151) leapsec++; // 1 July 1982
//# if(modified Julian Day>=45516) leapsec++; // 1 July 1983
//# if(modified Julian Day>=46247) leapsec++; // 1 July 1985
//# if(modified Julian Day>=47161) leapsec++; // 1 January 1988
//# if(modified Julian Day>=47892) leapsec++; // 1 January 1990
//# if(modified Julian Day>=48257) leapsec++; // 1 January 1991
//# if(modified Julian Day>=48804) leapsec++; // 1 July 1992
//# if(modified Julian Day>=49169) leapsec++; // 1 July 1993
//#
//# The function is invoked looks as follows
//#
//# <code>
//#
//# Time t;
//#
//# cout<<"Leap seconds "<< t.leapSeconds() <<"\n";
//#
//# </code>
//#
//# The function howManyDaysInMonth() return how many days are in a month.
//#
//# The function is invoked looks as follows
//#
//# <code>
//#
//# Time t;
//# uInt month=1,month2=2,year=1992;
//#
//# cout<<"how many days are in this month "<< howManyDaysInMonth() <<"\n"
//# cout<<"how many days are in January "<< howManyDaysInMonth(month) <<"\n";
//# cout<<"how many days are in february of 1992 "<<
//# howManyDaysInMonth(month,year) <<"\n"; // 1992 is a leap year
//#
//# </code>
//#
//# The function isLeapYear() return bool value. True if is a leap year
//# and False in other case.
//#
//# The function is invoked looks as follows
//#
//# <code>
//#
//# Time t;
//#
//# uInt year=1992;
//#
//# if(isLeapYear(year))
//# cout<<"Is a leap year";
//#
//# if(isLeapYear())
//# cout<<"This year is a leap year";
//#
//# </code>
|