WXP C++ Library Version 6.74.9
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
WXP::Date Class Reference

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

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

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

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 operator> (const Date &date)
 
int operator< (const Date &date)
 
void operator+= (const int rsecs)
 
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() [1/5]

Date::Date ( )

Constructor. Initializes values and sets to current time

References init().

◆ Date() [2/5]

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

Constructor. Initializes values and sets individual values

Parameters
ryearThe year (yyyy or 1900+yyy)
rmonthThe month (1-12)
rdayThe day (1-31)
rhourThe hour (0-23)
rminThe minute (0-59)
rsecThe second (0-59.99999)

References init(), and set().

◆ Date() [3/5]

Date::Date ( DateVal date)

Constructor. Initializes values and sets to DateVal values

Parameters
dateDate values from DateVal structure.

References init(), and set().

◆ Date() [4/5]

Date::Date ( long  rsecs)

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

Parameters
rsecsSeconds since 1/1/1970 (Unix time)

References init(), and set().

◆ Date() [5/5]

Date::Date ( char *  str)

Constructor. Sets values from string

Parameters
strDate as a string "yyyymmddhhnn.nnn"

References init(), and set().

Member Function Documentation

◆ addDays()

int Date::addDays ( int  days)

Adds days to date values and recomputes

Parameters
daysNumber of days to offset

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

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

◆ addHours()

int Date::addHours ( int  hours)

◆ addMinutes()

int Date::addMinutes ( int  mins)

Adds minutes to date values and recomputes

Parameters
minsNumber of minutes to offset

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

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

◆ addMonths()

int Date::addMonths ( int  months)

Adds months to date values and recomputes

Parameters
monthsNumber of months to offset

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

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

◆ addSeconds()

int Date::addSeconds ( float  rsec)

◆ addYears()

int Date::addYears ( int  years)

Adds years to date values and recomputes

Parameters
yearsNumber of years to offset

References WXP::DateVal::year.

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

◆ adjustHour() [1/3]

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

Adjusts the date according to new day/hour

Parameters
rdayNew day
rhourNew hour

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

◆ adjustHour() [2/3]

int Date::adjustHour ( int  rhour)

Adjusts the date according to new hour

Parameters
rhourNew hour

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

◆ adjustHour() [3/3]

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

Adjusts the date according to new month/day/hour

Parameters
rmonthNew month
rdayNew day
rhourNew hour

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

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

◆ adjustMinute() [1/3]

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

Adjusts the date according to new day/hour/minute

Parameters
rdayNew day
rhourNew hour
rminNew minutes

References adjustHour(), and setMinute().

◆ adjustMinute() [2/3]

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

Adjusts the date according to new hour/minute

Parameters
rhourNew hour
rminNew minutes

References adjustHour(), and setMinute().

◆ adjustMinute() [3/3]

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

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

Parameters
rmonthNew month
rdayNew day
rhourNew hour
rminNew minute

References adjustHour(), and setMinute().

Referenced by WXP::SynopTool::decode(), WXP::SfcWxpFile::read(), WXP::SfcXmlFile::read(), WXP::WatchFile::read(), WXP::RedbookFile::readHeader(), and WXP::WmoIngest::setAction().

◆ adjustSecond()

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

Adjusts the date according to new hour/minute/seconds

Parameters
rhourNew hour
rminNew minutes
rsecNew seconds

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

◆ changeTimezone()

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

Changes the time zone parameters

Parameters
roffTime zone offset in seconds (EST = -18000)
tzString describing timezone (EST)

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

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

◆ fix()

int Date::fix ( )

◆ get()

DateVal Date::get ( )

◆ getCurrentSeconds()

long Date::getCurrentSeconds ( )
static

This function returns the current time in seconds

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

Referenced by set().

◆ getDay()

int WXP::Date::getDay ( )
inline

◆ getDayOfWeek()

int Date::getDayOfWeek ( )

Gets the day of week

Returns
Day of week (0-6)

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

◆ getDays()

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.

◆ getHour()

int WXP::Date::getHour ( )
inline

◆ getJulian() [1/2]

int Date::getJulian ( )

Gets the julian day

Returns
Julian day of year (1-366)

Referenced by WXP::NameConv::encode(), and WXP::WmoIngest::setAction().

◆ getJulian() [2/2]

int Date::getJulian ( int  year,
int  month,
int  day 
)
static

Computes Julian day

Parameters
yearYear
monthMonth
dayDay

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

◆ getMinute()

int WXP::Date::getMinute ( )
inline

◆ getMonth()

int WXP::Date::getMonth ( )
inline

◆ getSecond()

float WXP::Date::getSecond ( )
inline

◆ getSeconds()

int Date::getSeconds ( )

◆ getVals()

int Date::getVals ( DateVal date)

Gets the date values

Return values
dateDateVal structure to receive values

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

Referenced by WXP::SatCdfFile::readHeader().

◆ getYear()

int WXP::Date::getYear ( )
inline

◆ getYear00()

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().

◆ init()

int Date::init ( )

◆ isLeap()

bool Date::isLeap ( )

Checks if year a leap year

Returns
True if a leap year

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

Referenced by setDays().

◆ isSet()

bool Date::isSet ( )

◆ isYearLeap()

bool Date::isYearLeap ( int  year)
static

Checks for leap year given a year

Parameters
yearYear (yyyy)
Returns
True if a leap year

References WXP::DateVal::year.

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

◆ print()

int Date::print ( )

◆ printSeconds()

int Date::printSeconds ( )

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

◆ set() [1/7]

int Date::set ( )

Sets the date values based on current time

References getCurrentSeconds(), and set().

Referenced by addDays(), addHours(), addMinutes(), addSeconds(), changeTimezone(), Date(), Date(), Date(), Date(), set(), and set().

◆ set() [2/7]

int Date::set ( const char *  str)

◆ set() [3/7]

int WXP::Date::set ( Date rdate)
inline

Sets date given another Date class

◆ set() [4/7]

int Date::set ( DateVal date)

◆ set() [5/7]

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

Sets the date values with DateVal values and timezone

Parameters
dateDate values from DateVal structure.
roffOffset in seconds from UTC of timezone (-18000 for EST)
tzCharacter 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.

◆ set() [6/7]

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

Sets the date values individually.

Parameters
ryearThe year (yyyy or 1900+yyy)
rmonthThe month (1-12)
rdayThe day (1-31)
rhourThe hour (0-23)
rminThe minute (0-59)
rsecThe second (0-59.99999)

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.

◆ set() [7/7]

int Date::set ( long  rsecs)

Sets the date values based on time in seconds

Parameters
rsecsSeconds 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.

◆ setDay()

int Date::setDay ( int  val)

Sets the day

Parameters
valDay (1-31)

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

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

◆ setDays()

int Date::setDays ( int  days)

Sets date values using days since 1/1/1970

Parameters
daysDays 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.

Referenced by WXP::LritFile::getHeader(), and WXP::LightFile::read().

◆ setFractionalSecond()

int Date::setFractionalSecond ( float  val)

Sets the fractional seconds

Parameters
valFractional seconds (0-0.999999)

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

Referenced by WXP::LightData::setFsec().

◆ setHour()

int Date::setHour ( int  val)

Sets the hour

Parameters
valHour (0-23)

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

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

◆ setJulian() [1/2]

int Date::setJulian ( int  val)

Sets day of year from Julian day

Parameters
valJulian day

References WXP::DateVal::day, WXP::DateVal::month, setJulian(), and WXP::DateVal::year.

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

◆ setJulian() [2/2]

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

Sets day of year from Julian day

Parameters
yearYear to use (test for leap year)
jdayJulian day (1-366)
Return values
monthMonth of year
dayDay of year

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

◆ setMinute()

int Date::setMinute ( int  val)

◆ setMonth()

int Date::setMonth ( int  val)

Sets the month

Parameters
valMonth (1-12)

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

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

◆ setSecond()

int Date::setSecond ( float  val)

Sets the second

Parameters
valSecond (0-59.9999)

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

Referenced by adjustSecond(), and WXP::LightFile::read().

◆ setTime() [1/2]

int Date::setTime ( float  rsecs)

Sets time using seconds since midnight

Parameters
rsecsSeconds since midnight

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

◆ setTime() [2/2]

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

Sets the time values only

Parameters
rhourThe hour (0-23)
rminThe minute (0-59)
rsecThe second (0-59.99999)

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

Referenced by WXP::LritFile::getHeader().

◆ setYear()

int Date::setYear ( int  val)

Sets the year

Parameters
valYear (yyyy or 1900+yyy)

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

◆ toString()

int Date::toString ( String str)

Output date values to string

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

References toText().

◆ toText() [1/2]

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

Creates a string from the date values

Parameters
formFormat 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
strOutput 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.

◆ toText() [2/2]

int Date::toText ( String str)

Output date values to string

Return values
strOutput 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, WXP::DateVal::sec, and toText().

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


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