SourcePro® API Reference Guide

 
List of all members | Public Member Functions | Related Functions
RWTimeTuple Class Reference

Represents a date and time stored as a named tuple of each component. More...

#include <rw/tools/timetuple.h>

Public Member Functions

 RWTimeTuple ()
 
 RWTimeTuple (int year, int mon, int mday, int hour, int min, int sec, rwint64 pico)
 
 RWTimeTuple (const RWDate &date, int hour=0, int min=0, int sec=0, rwint64 pico=0)
 
 RWTimeTuple (const RWDateTime &dt, const RWZone &zone=RWZone::local())
 
 RWTimeTuple (const RWTimeTupleOffset &tt)
 
 RWTimeTuple (const struct tm *t, rwint64 pico=0)
 
 RWTimeTuple (const RWTimeTuple &other)
 
int dayOfMonth () const
 
void dayOfMonth (int d)
 
void extract (struct tm *tt) const
 
int hour () const
 
void hour (int h)
 
int minute () const
 
void minute (int m)
 
int month () const
 
void month (int m)
 
RWTimeTupleoperator= (const RWTimeTuple &other)
 
rwint64 picosecond () const
 
void picosecond (rwint64 p)
 
int second () const
 
void second (int s)
 
int year () const
 
void year (int y)
 

Related Functions

(Note that these are not member functions.)

RWvostreamoperator<< (RWvostream &str, const RWTimeTuple &t)
 
RWFileoperator<< (RWFile &file, const RWTimeTuple &t)
 
RWvistreamoperator>> (RWvistream &str, RWTimeTuple &t)
 
RWFileoperator>> (RWFile &file, RWTimeTuple &t)
 
RWvistreamoperator>> (RWvistream &str, RWTimeTuple *&t)
 
RWFileoperator>> (RWFile &file, RWTimeTuple *&t)
 

Detailed Description

RWTimeTuple represents a date and time, stored as a tuple of each calendar component (e.g. year, month, day, hour, minute, second, picosecond).

RWTimeTuple may be useful when individual calendar components will be accessed/modified, but where comparisons and calculations on the overall date/time aren't required. In cases where comparisons and calculations are required, see RWDateTime.

RWTimeTuple does not capture an offset from GMT, and instead represents a date/time in local time (similar to struct tm). In cases where a specific instance in time should be represented, RWTimeTupleOffset should be used.

See also
RWTimeTupleFormatter for details on formatting a RWTimeTuple.

Constructor & Destructor Documentation

RWTimeTuple::RWTimeTuple ( )
inline

Default constructor. All fields of the RWTimeTuple instance are set to -1.

RWTimeTuple::RWTimeTuple ( int  year,
int  mon,
int  mday,
int  hour,
int  min,
int  sec,
rwint64  pico 
)
inline

Constructs each field of the RWTimeTuple.

RWTimeTuple::RWTimeTuple ( const RWDate date,
int  hour = 0,
int  min = 0,
int  sec = 0,
rwint64  pico = 0 
)
explicit

Constructs an RWTimeTuple based on the year, month and day of the month from date and other fields as specified in the parameters. If date is invalid, all fields in RWTimeTuple are set to -1.

Note
If date has a julian day number greater than 392446299155, the value of the resulting RWTimeTuple is undefined.
RWTimeTuple::RWTimeTuple ( const RWDateTime dt,
const RWZone zone = RWZone::local() 
)
explicit

Constructs an RWTimeTuple based on the date/time information in dt, as interpreted in the time zone zone. If dt is a sentinel value, all fields in RWTimeTuple are set to -1. Otherwise, this function retrieves the date and time components from dt using dt.extract()'.

See also
RWDateTime::extract(struct tm *, const RWZone&)const for limitations on the date-time values supported.
RWTimeTuple::RWTimeTuple ( const RWTimeTupleOffset tt)
explicit

Constructs an RWTimeTuple based on the contents of tt. The GMT offset of tt is ignored.

RWTimeTuple::RWTimeTuple ( const struct tm *  t,
rwint64  pico = 0 
)
inlineexplicit

Constructs an RWTimeTuple based on the date/time information in t.

Note
If t->tm_year > INT_MAX - 1900 or if t->tm_mon > INT_MAX - 1, the results are undefined.
RWTimeTuple::RWTimeTuple ( const RWTimeTuple other)
inline

Copy constructor.

Member Function Documentation

int RWTimeTuple::dayOfMonth ( ) const
inline

Returns the day of the month.

void RWTimeTuple::dayOfMonth ( int  d)
inline

Sets the day of the month to d.

void RWTimeTuple::extract ( struct tm *  tt) const
inline

Populates the struct tm tt based on the values in self. The fields tm_wday, tm_yday and tm_isdst are set to -1 as that information is not known in RWTimeTuple. The picoseconds value of the RWTimeTuple is ignored.

Note
If getYear() < INT_MIN + 1900 or if getMonth() < INT_MIN + 1, the results are undefined.
int RWTimeTuple::hour ( ) const
inline

Returns the number of hours.

void RWTimeTuple::hour ( int  h)
inline

Sets the number of hours to h.

int RWTimeTuple::minute ( ) const
inline

Returns the number of minutes.

void RWTimeTuple::minute ( int  m)
inline

Sets the number of minutes to m.

int RWTimeTuple::month ( ) const
inline

Returns the month index (0 == January).

void RWTimeTuple::month ( int  m)
inline

Sets the month index to m (0 == January).

RWTimeTuple & RWTimeTuple::operator= ( const RWTimeTuple other)
inline

Assignment operator.

rwint64 RWTimeTuple::picosecond ( ) const
inline

Returns the number of picoseconds.

void RWTimeTuple::picosecond ( rwint64  p)
inline

Sets the number of picoseconds to p.

int RWTimeTuple::second ( ) const
inline

Returns the number of seconds.

void RWTimeTuple::second ( int  s)
inline

Sets the number of seconds to s.

int RWTimeTuple::year ( ) const
inline

Returns the year.

void RWTimeTuple::year ( int  y)
inline

Sets the year to y.

Friends And Related Function Documentation

RWvostream & operator<< ( RWvostream str,
const RWTimeTuple t 
)
related

Saves t to a virtual stream.

RWFile & operator<< ( RWFile file,
const RWTimeTuple t 
)
related

Saves t to an RWFile.

RWvistream & operator>> ( RWvistream str,
RWTimeTuple t 
)
related

Restores t from a virtual stream, replacing the previous contents of t.

RWFile & operator>> ( RWFile file,
RWTimeTuple t 
)
related

Restores t from an RWFile, replacing the previous contents of t.

RWvistream & operator>> ( RWvistream str,
RWTimeTuple *&  t 
)
related

Restores an RWTimeTuple from a virtual stream by allocating an RWDateTime on the heap and restoring its state.

RWFile & operator>> ( RWFile file,
RWTimeTuple *&  t 
)
related

Restores an RWTimeTuple from an RWFile by allocating an RWTimeTuple on the heap and restoring its state.

Copyright © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.