SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
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 (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 RWTimeTuple &other)
 
 RWTimeTuple (const RWTimeTupleOffset &tt)
 
 RWTimeTuple (const struct tm *t, rwint64 pico=0)
 
 RWTimeTuple (int year, int mon, int mday, int hour, int min, int sec, rwint64 pico)
 
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)
 

Friends

struct RWTHash< RWTimeTuple >
 

Related Symbols

(Note that these are not member symbols.)

RWFileoperator<< (RWFile &file, const RWTimeTuple &t)
 
RWvostreamoperator<< (RWvostream &str, const RWTimeTuple &t)
 
RWFileoperator>> (RWFile &file, RWTimeTuple &t)
 
RWFileoperator>> (RWFile &file, RWTimeTuple *&t)
 
RWvistreamoperator>> (RWvistream &str, RWTimeTuple &t)
 
RWvistreamoperator>> (RWvistream &str, 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() [1/7]

RWTimeTuple::RWTimeTuple ( )
inline

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

◆ RWTimeTuple() [2/7]

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

Constructs each field of the RWTimeTuple.

◆ RWTimeTuple() [3/7]

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() [4/7]

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() [5/7]

RWTimeTuple::RWTimeTuple ( const RWTimeTupleOffset & tt)
explicit

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

◆ RWTimeTuple() [6/7]

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() [7/7]

RWTimeTuple::RWTimeTuple ( const RWTimeTuple & other)
inline

Copy constructor.

Member Function Documentation

◆ dayOfMonth() [1/2]

int RWTimeTuple::dayOfMonth ( ) const
inline

Returns the day of the month.

◆ dayOfMonth() [2/2]

void RWTimeTuple::dayOfMonth ( int d)
inline

Sets the day of the month to d.

◆ extract()

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.

◆ hour() [1/2]

int RWTimeTuple::hour ( ) const
inline

Returns the number of hours.

◆ hour() [2/2]

void RWTimeTuple::hour ( int h)
inline

Sets the number of hours to h.

◆ minute() [1/2]

int RWTimeTuple::minute ( ) const
inline

Returns the number of minutes.

◆ minute() [2/2]

void RWTimeTuple::minute ( int m)
inline

Sets the number of minutes to m.

◆ month() [1/2]

int RWTimeTuple::month ( ) const
inline

Returns the month index (0 == January).

◆ month() [2/2]

void RWTimeTuple::month ( int m)
inline

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

◆ operator=()

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

Assignment operator.

◆ picosecond() [1/2]

rwint64 RWTimeTuple::picosecond ( ) const
inline

Returns the number of picoseconds.

◆ picosecond() [2/2]

void RWTimeTuple::picosecond ( rwint64 p)
inline

Sets the number of picoseconds to p.

◆ second() [1/2]

int RWTimeTuple::second ( ) const
inline

Returns the number of seconds.

◆ second() [2/2]

void RWTimeTuple::second ( int s)
inline

Sets the number of seconds to s.

◆ year() [1/2]

int RWTimeTuple::year ( ) const
inline

Returns the year.

◆ year() [2/2]

void RWTimeTuple::year ( int y)
inline

Sets the year to y.

Friends And Related Symbol Documentation

◆ operator<<() [1/2]

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

Saves t to an RWFile.

◆ operator<<() [2/2]

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

Saves t to a virtual stream.

◆ operator>>() [1/4]

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

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

◆ operator>>() [2/4]

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

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

◆ operator>>() [3/4]

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

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

◆ operator>>() [4/4]

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.

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