WXP::Date Class Reference

This class stores date and time information. More...

#include "../include/Date.h"

Inheritance diagram for WXP::Date:
WXP::DateVal

List of all members.

Public Member Functions

 Date ()
 Date (int ryear, int rmonth, int rday, int rhour, int rmin, float rsec)
 Date (DateVal &date)
 Date (long secs)
 Date (char *str)
int init ()
bool isSet ()
int set (const char *str)
int set (int ryear, int rmonth, int rday, int rhour, int rmin, float rsec)
int set (Date &rdate)
int set (DateVal &date)
int set (DateVal &date, int roff, const char *tz)
int set (long secs)
int set ()
int getVals (DateVal &date)
DateVal get ()
int setYear (int val)
int getYear ()
int getYear00 ()
int setMonth (int val)
int getMonth ()
int setDay (int val)
int getDay ()
int setHour (int val)
int getHour ()
int setMinute (int val)
int getMinute ()
int setSecond (float val)
int setFractionalSecond (float val)
float getSecond ()
int getSeconds ()
bool isLeap ()
int setDays (int days)
int setTime (int rhour, int rmin, float rsec)
int setTime (float rsecs)
int getDays ()
int addYears (int years)
int addMonths (int months)
int addDays (int days)
int addHours (int hours)
int addMinutes (int mins)
int addSeconds (float secs)
int getDayOfWeek ()
int getJulian ()
int setJulian (int val)
int toString (String &str)
int toText (String &str)
int toText (const char *form, String &str)
int changeTimezone (int roff, const char *tz)
int adjustMinute (int rmonth, int rday, int rhour, int rmin)
int adjustMinute (int rday, int rhour, int rmin)
int adjustMinute (int rhour, int rmin)
int adjustSecond (int rhour, int rmin, int rsec)
int adjustHour (int rmonth, int rday, int rhour)
int adjustHour (int rday, int rhour)
int adjustHour (int rhour)
int fix ()
int print ()
int printSeconds ()

Static Public Member Functions

static long getCurrentSeconds ()
static bool isYearLeap (int year)
static int setJulian (int year, int jday, int &month, int &day)
static int getJulian (int year, int month, int day)

Detailed Description

This class stores date and time information.

Author:
Dan Vietor

Constructor & Destructor Documentation

Date::Date (  ) 

Constructor. Initializes values and sets to current time

References init().

Date::Date ( int  ryear,
int  rmonth,
int  rday,
int  rhour,
int  rmin,
float  rsec 
)

Constructor. Initializes values and sets individual values

References init().

Date::Date ( DateVal date  ) 

Constructor. Initializes values and sets to DateVal values

References init().

Date::Date ( long  rsecs  ) 

Constructor. Initializes values and sets values from seconds since 1/1/1970

Parameters:
rsecs Seconds since 1/1/1970 (Unix time)

References init().

Date::Date ( char *  str  ) 

Constructor. Sets values from string

Parameters:
str Date as a string "yyyymmddhhnn.nnn"

References init().


Member Function Documentation

int Date::addDays ( int  days  ) 

Adds days to date values and recomputes

Parameters:
days Number of days to offset

References WXP::DateVal::day, WXP::DateVal::hour, WXP::DateVal::min, WXP::Const::MISS, and WXP::DateVal::sec.

Referenced by adjustHour(), and WXP::NameConv::setLatest().

int Date::addHours ( int  hours  ) 
int Date::addMinutes ( int  mins  ) 

Adds minutes to date values and recomputes

Parameters:
mins Number of minutes to offset

References WXP::DateVal::day, WXP::DateVal::hour, WXP::DateVal::min, WXP::Const::MISS, and WXP::DateVal::sec.

Referenced by WXP::Figure::endPlot().

int Date::addMonths ( int  months  ) 

Adds months to date values and recomputes

Parameters:
months Number of months to offset

References WXP::DateVal::month, and WXP::DateVal::year.

Referenced by adjustHour(), and WXP::NameConv::setLatest().

int Date::addSeconds ( float  rsec  ) 

Adds seconds to date values and recomputes

Parameters:
sec Number of seconds to offset

References WXP::DateVal::day, WXP::DateVal::hour, WXP::DateVal::min, WXP::Const::MISS, and WXP::DateVal::sec.

Referenced by WXP::DateTool::createLabel(), WXP::Filename::setFile(), and WXP::NameConv::setLatest().

int Date::addYears ( int  years  ) 

Adds years to date values and recomputes

Parameters:
years Number of years to offset

References WXP::DateVal::year.

Referenced by WXP::NameConv::setLatest().

int Date::adjustHour ( int  rhour  ) 

Adjusts the date according to new hour

Parameters:
rhour New hour

References addDays(), WXP::DateVal::hour, setHour(), and WXP::DateVal::validate().

int Date::adjustHour ( int  rday,
int  rhour 
)

Adjusts the date according to new day/hour

Parameters:
rday New day
rhour New hour

References addDays(), addMonths(), WXP::DateVal::day, WXP::DateVal::hour, setDay(), setHour(), and WXP::DateVal::validate().

int Date::adjustHour ( int  rmonth,
int  rday,
int  rhour 
)

Adjusts the date according to new month/day/hour

Parameters:
rmonth New month
rday New day
rhour New hour

References WXP::DateVal::month, setDay(), setHour(), setMonth(), WXP::DateVal::validate(), and WXP::DateVal::year.

Referenced by adjustMinute(), adjustSecond(), WXP::SynopTool::decode(), WXP::SaoTool::decode(), WXP::MetarTool::decode(), and WXP::UpaWmoFile::read().

int Date::adjustMinute ( int  rhour,
int  rmin 
)

Adjusts the date according to new hour/minute

Parameters:
rhour New hour
rmin New minutes

References adjustHour(), and setMinute().

int Date::adjustMinute ( int  rday,
int  rhour,
int  rmin 
)

Adjusts the date according to new day/hour/minute

Parameters:
rday New day
rhour New hour
rmin New minutes

References adjustHour(), and setMinute().

int Date::adjustMinute ( int  rmonth,
int  rday,
int  rhour,
int  rmin 
)

Adjusts the date according to new month/day/hour/minute

Parameters:
rmonth New month
rday New day
rhour New hour
rmin New minute

References adjustHour(), and setMinute().

Referenced by WXP::SynopTool::decode(), WXP::SfcXmlFile::read(), and WXP::SfcWxpFile::read().

int Date::adjustSecond ( int  rhour,
int  rmin,
int  rsec 
)

Adjusts the date according to new hour/minute/seconds

Parameters:
rhour New hour
rmin New minutes
rsec New seconds

References adjustHour(), setMinute(), and setSecond().

int Date::changeTimezone ( int  roff,
const char *  tz 
)

Changes the time zone parameters

Parameters:
roff Time zone offset in seconds (EST = -18000)
tz String describing timezone (EST)

References WXP::StrLib::copy(), WXP::DateVal::day, WXP::DateVal::hour, WXP::DateVal::min, WXP::Const::MISS, and WXP::DateVal::sec.

Referenced by WXP::DateTool::createLabel().

int Date::fix (  ) 
DateVal Date::get (  ) 
long Date::getCurrentSeconds (  )  [static]

This function returns the current time in seconds

Returns:
Seconds since 1/1/1970 (Unix time)

Referenced by set().

int WXP::Date::getDay (  )  [inline]
int Date::getDayOfWeek (  ) 

Gets the day of week

Returns:
Day of week (0-6)

Referenced by WXP::DateTool::createLabel().

int Date::getDays (  ) 

Gets number of days since 1/1/1970

Returns:
Days since 1/1/1970

References WXP::DateVal::day, WXP::DateVal::month, WXP::DateVal::num_day, and WXP::DateVal::year.

int WXP::Date::getHour (  )  [inline]
int Date::getJulian ( int  year,
int  month,
int  day 
) [static]

Computes Julian day

Parameters:
year Year
month Month
day Day

References isYearLeap(), WXP::DateVal::num_day, and WXP::DateVal::num_day_leap.

int Date::getJulian (  ) 

Gets the julian day

Returns:
Julian day of year (1-366)

Referenced by WXP::NameConv::encode().

int WXP::Date::getMinute (  )  [inline]
int WXP::Date::getMonth (  )  [inline]
float WXP::Date::getSecond (  )  [inline]

Gets the seconds

Reimplemented from WXP::DateVal.

References WXP::DateVal::sec.

Referenced by WXP::DateTool::createLabel(), and WXP::LightPlot::draw().

int Date::getSeconds (  ) 
int Date::getVals ( DateVal date  ) 

Gets the date values

Parameters:
date DateVal structure to receive values

References WXP::DateVal::day, WXP::DateVal::hour, WXP::DateVal::min, WXP::DateVal::month, WXP::DateVal::sec, and WXP::DateVal::year.

int WXP::Date::getYear (  )  [inline]

Gets the year (yyyy)

Reimplemented from WXP::DateVal.

References WXP::DateVal::year.

Referenced by WXP::SfcUniFile::open(), and WXP::NameConv::setLatest().

int Date::getYear00 (  ) 

Gets the year (from 1900)

Returns:
Years since 1900

References WXP::Const::MISS, and WXP::DateVal::year.

Referenced by WXP::DateTool::createLabel().

int Date::init (  ) 
bool Date::isLeap (  ) 

Checks if year a leap year

Returns:
True if a leap year

References isYearLeap(), and WXP::DateVal::year.

Referenced by setDays().

bool Date::isSet (  ) 
bool Date::isYearLeap ( int  year  )  [static]

Checks for leap year given a year

Parameters:
year Year (yyyy)
Returns:
True if a leap year

Referenced by getJulian(), isLeap(), and setJulian().

int Date::print (  ) 
int Date::printSeconds (  ) 

Prints the internal seconds (since 1/1/70)

int Date::set (  ) 

Sets the date values based on current time

References getCurrentSeconds().

int Date::set ( long  rsecs  ) 

Sets the date values based on time in seconds

Parameters:
rsecs Seconds since 1/1/1970 (Unix time)

References WXP::DateVal::day, WXP::DateVal::hour, WXP::DateVal::min, WXP::DateVal::month, WXP::DateVal::sec, and WXP::DateVal::year.

int Date::set ( DateVal date,
int  roff,
const char *  tz 
)

Sets the date values with DateVal values and timezone

Parameters:
date Date values from DateVal structure.
roff Offset in seconds from UTC of timezone (-18000 for EST)
tz Character string describing timezone (EST)

References WXP::StrLib::copy(), WXP::DateVal::day, WXP::DateVal::hour, init(), WXP::DateVal::min, WXP::Const::MISS, WXP::DateVal::month, WXP::DateVal::sec, setJulian(), WXP::DateVal::validate(), and WXP::DateVal::year.

int Date::set ( DateVal date  ) 
int WXP::Date::set ( Date rdate  )  [inline]

Sets date given another Date class

int Date::set ( int  ryear,
int  rmonth,
int  rday,
int  rhour,
int  rmin,
float  rsec 
)

Sets the date values individually.

Parameters:
ryear The year (yyyy or 1900+yyy)
rmonth The month (1-12)
rday The day (1-31)
rhour The hour (0-23)
rmin The minute (0-59)
rsec The second (0-59.99999)

Reimplemented from WXP::DateVal.

References WXP::DateVal::day, WXP::DateVal::hour, init(), WXP::DateVal::min, WXP::Const::MISS, WXP::DateVal::month, WXP::DateVal::sec, setJulian(), WXP::DateVal::validate(), and WXP::DateVal::year.

int Date::set ( const char *  str  ) 
int Date::setDay ( int  val  ) 

Sets the day

Parameters:
val Day (1-31)

Reimplemented from WXP::DateVal.

References WXP::DateVal::day, and WXP::Const::MISS.

Referenced by adjustHour(), and WXP::NameConv::setLatest().

int Date::setDays ( int  days  ) 

Sets date values using days since 1/1/1970

Parameters:
days Days since 1/1/1970

References WXP::DateVal::day, isLeap(), WXP::DateVal::month, WXP::DateVal::num_day, WXP::DateVal::num_day_leap, and WXP::DateVal::year.

int Date::setFractionalSecond ( float  val  ) 

Sets the fractional seconds

Parameters:
val Fractional seconds (0-0.999999)

References WXP::Const::MISS, and WXP::DateVal::sec.

int Date::setHour ( int  val  ) 

Sets the hour

Parameters:
val Hour (0-23)

Reimplemented from WXP::DateVal.

References WXP::DateVal::hour, and WXP::Const::MISS.

Referenced by adjustHour(), and WXP::NameConv::setLatest().

int Date::setJulian ( int  year,
int  jday,
int &  month,
int &  day 
) [static]

Sets day of year from Julian day

Parameters:
year Year to use (test for leap year)
jday Julian day (1-366)
Return values:
month Month of year
day Day of year

References isYearLeap(), WXP::DateVal::num_day, and WXP::DateVal::num_day_leap.

int Date::setJulian ( int  val  ) 

Sets day of year from Julian day

Parameters:
val Julian day

References WXP::DateVal::day, WXP::DateVal::month, and WXP::DateVal::year.

Referenced by WXP::NameConv::decode(), and set().

int Date::setMinute ( int  val  ) 
int Date::setMonth ( int  val  ) 

Sets the month

Parameters:
val Month (1-12)

Reimplemented from WXP::DateVal.

References WXP::Const::MISS, and WXP::DateVal::month.

Referenced by adjustHour(), and WXP::NameConv::setLatest().

int Date::setSecond ( float  val  ) 

Sets the second

Parameters:
val Second (0-59.9999)

Reimplemented from WXP::DateVal.

References WXP::Const::MISS, and WXP::DateVal::sec.

Referenced by adjustSecond().

int Date::setTime ( float  rsecs  ) 

Sets time using seconds since midnight

Parameters:
rsecs Seconds since midnight

References WXP::DateVal::hour, WXP::DateVal::min, and WXP::DateVal::sec.

int Date::setTime ( int  rhour,
int  rmin,
float  rsec 
)

Sets the time values only

Parameters:
rhour The hour (0-23)
rmin The minute (0-59)
rsec The second (0-59.99999)

References WXP::DateVal::hour, init(), WXP::DateVal::min, WXP::DateVal::sec, and WXP::DateVal::validate().

int Date::setYear ( int  val  ) 

Sets the year

Parameters:
val Year (yyyy or 1900+yyy)

Reimplemented from WXP::DateVal.

References WXP::Const::MISS, and WXP::DateVal::year.

int Date::toString ( String str  ) 

Output date values to string

Return values:
str Output string using format "%Y%m%d%H%M%S"
See also:
Date::toText(char *,String &)

References toText().

int Date::toText ( const char *  form,
String str 
)

Creates a string from the date values

Parameters:
form Format string
%a = day of week (SUN-SAT)
%b = month (JAN-DEC)
%Y = year (yyyy)
%y = year (yy)
%m = month (mm)
%d = day (dd)
%e = day ( d or dd)
%j = julian day (001-366)
%H = hour (00-23)
%l = hour (00-12)
%p = AM/PM
%M = minute (00-59)
%S = second (00-59)
%s = second (00.0000-59.9999)
%u = day of week (0-6)
%Z = time zone string
Return values:
str Output string

References WXP::String::append(), WXP::String::aprintf(), WXP::String::clear(), WXP::DateVal::day, WXP::StrLib::equal(), WXP::DateVal::hour, WXP::DateVal::min, WXP::Const::MISS, WXP::DateVal::month, WXP::DateVal::sec, and WXP::DateVal::year.

int Date::toText ( String str  ) 

Output date values to string

Return values:
str Output string using format "%H:%M:%S%Z %e %b %Y"
See also:
Date::toText(char *,String &)

References WXP::DateVal::hour, WXP::DateVal::min, WXP::Const::MISS, and WXP::DateVal::sec.

Referenced by WXP::WatchPlot::draw(), WXP::DateTool::getCurrent(), WXP::GribFile::makeDatim(), and toString().


The documentation for this class was generated from the following files:

Generated on 8 Jan 2010 for WXP C++ Library by  doxygen 1.6.1