plptools
Loading...
Searching...
No Matches
PsiTime Class Reference

Psion time related utility class. More...

#include <psitime.h>

Collaboration diagram for PsiTime:

Public Types

enum  zone {
  PSI_TZ_NONE = 0 , PSI_TZ_EUROPEAN = 1 , PSI_TZ_NORTHERN = 2 , PSI_TZ_SOUTHERN = 4 ,
  PSI_TZ_HOME = 0x40000000
}
 

Public Member Functions

 PsiTime (struct timeval *_utv, struct timezone *_utz=nullptr)
 Contructs a new instance. More...
 
 PsiTime (time_t time)
 Contructs a new instance. More...
 
 PsiTime (psi_timeval *_ptv, psi_timezone *_ptz=nullptr)
 Contructs a new instance. More...
 
 PsiTime (const uint32_t _ptvHi, const uint32_t _ptvLo)
 Contructs a new instance. More...
 
 PsiTime (void)
 Constructs a new instance, initializing to now. More...
 
 PsiTime (const PsiTime &t)
 A copy-constructor. More...
 
 ~PsiTime ()
 Destroys the instance. More...
 
void setPsiTime (psi_timeval *_ptv)
 Modifies the value of this instance. More...
 
void setSiboTime (uint32_t stime)
 Modifies the value of this instance. More...
 
void setPsiTime (const uint32_t _ptvHi, const uint32_t _ptvLo)
 Modifies the value of this instance. More...
 
void setPsiZone (psi_timezone *_ptz)
 Sets the Psion time zone of this instance. More...
 
void setUnixTime (struct timeval *_utv)
 Sets the value of this instance. More...
 
void setUnixTime (time_t time)
 Sets the value of this instance. More...
 
void setUnixNow (void)
 Sets the value of this instance to the current time of the Unix machine. More...
 
struct timeval & getTimeval (void)
 Retrieves the instance's current value in Unix time format. More...
 
time_t getTime (void)
 Retrieves the instance's current value in Unix time format. More...
 
uint32_t getSiboTime ()
 Retrieves the instance's current value in SIBO time format. More...
 
psi_timevalgetPsiTimeval (void)
 Retrieves the instance's current value in Psion time format. More...
 
uint32_t getPsiTimeLo (void)
 Retrieves the instance's current value in Psion time format, high 32 bits. More...
 
uint32_t getPsiTimeHi (void)
 Retrieves the instance's current value in Psion time format, low 32 bits. More...
 
PsiTimeoperator= (const PsiTime &t)
 Assignment operator. More...
 
bool operator== (const PsiTime &t)
 Comparison operators. More...
 
bool operator< (const PsiTime &t)
 
bool operator> (const PsiTime &t)
 

Private Member Functions

void psi2unix (void)
 
void unix2psi (void)
 
void tryPsiZone ()
 

Private Attributes

psi_timeval ptv
 
psi_timezone ptz
 
struct timeval utv
 
struct timezone utz
 
bool ptzValid
 

Friends

std::ostreamoperator<< (std::ostream &s, const PsiTime &t)
 Prints the instance's value in human readable format. More...
 

Detailed Description

Psion time related utility class.

PsiTime provides easy access to the time format, used when communicating with a Psion. Internally, the time is always normalized to GMT. The time value can be set and retrieved in both Unix and Psion formats. This allows easy conversion between both formats. NOTE: For proper conversion, the current timezone of the Psion has to be set. For EPOC devices, the timezone can be evaluated using rpcs::getMachineInfo . For SIBO devices, unfortunately there is no known method of retrieving this information. Therefore, if the timezone is not set, a fallback using the environment variable PSI_TZ is provided. Users should set this variable to the offset of their time zone in seconds. If PSI_TZ is net set, a second fallback uses the local machine's setup, which assumes that both Psion and local machine have the same time zone and daylight settings.

Author
Fritz Elfert felfe.nosp@m.rt@t.nosp@m.o.com

Definition at line 125 of file psitime.h.

Member Enumeration Documentation

◆ zone

Enumerator
PSI_TZ_NONE 
PSI_TZ_EUROPEAN 
PSI_TZ_NORTHERN 
PSI_TZ_SOUTHERN 
PSI_TZ_HOME 

Definition at line 296 of file psitime.h.

Constructor & Destructor Documentation

◆ PsiTime() [1/6]

PsiTime::PsiTime ( struct timeval *  _utv,
struct timezone *  _utz = nullptr 
)

Contructs a new instance.

Parameters
_utvA Unix time value for initialization.
_utzA Unix timezone for initialization.

Definition at line 68 of file psitime.cc.

◆ PsiTime() [2/6]

PsiTime::PsiTime ( time_t  time)

Contructs a new instance.

Parameters
timeA Unix time value for initialization.

Definition at line 37 of file psitime.cc.

◆ PsiTime() [3/6]

PsiTime::PsiTime ( psi_timeval _ptv,
psi_timezone _ptz = nullptr 
)

Contructs a new instance.

Parameters
_ptvA Psion time value for initialization.
_ptzA Psion timezone for initialization.

Definition at line 43 of file psitime.cc.

◆ PsiTime() [4/6]

PsiTime::PsiTime ( const uint32_t  _ptvHi,
const uint32_t  _ptvLo 
)

Contructs a new instance.

Parameters
_ptvHiThe high 32 bits of a Psion time value for initialization.
_ptvLoThe low 32 bits of a Psion time value for initialization.

Definition at line 58 of file psitime.cc.

◆ PsiTime() [5/6]

PsiTime::PsiTime ( void  )

Constructs a new instance, initializing to now.

Definition at line 31 of file psitime.cc.

◆ PsiTime() [6/6]

PsiTime::PsiTime ( const PsiTime t)

A copy-constructor.

Definition at line 77 of file psitime.cc.

◆ ~PsiTime()

PsiTime::~PsiTime ( )

Destroys the instance.

Definition at line 86 of file psitime.cc.

Member Function Documentation

◆ getPsiTimeHi()

uint32_t PsiTime::getPsiTimeHi ( void  )

Retrieves the instance's current value in Psion time format, low 32 bits.

Returns
The instance's current time as upper 32 bits of a Psion struct psi_timeval_t.

Definition at line 144 of file psitime.cc.

◆ getPsiTimeLo()

uint32_t PsiTime::getPsiTimeLo ( void  )

Retrieves the instance's current value in Psion time format, high 32 bits.

Returns
The instance's current time as lower 32 bits of a Psion struct psi_timeval_t.

Definition at line 140 of file psitime.cc.

◆ getPsiTimeval()

psi_timeval & PsiTime::getPsiTimeval ( void  )

Retrieves the instance's current value in Psion time format.

Returns
The instance's current time a Psion struct psi_timeval_t.

Definition at line 136 of file psitime.cc.

◆ getSiboTime()

uint32_t PsiTime::getSiboTime ( void  )

Retrieves the instance's current value in SIBO time format.

Returns
The instance's current time as SIBO time.

Definition at line 246 of file psitime.cc.

◆ getTime()

time_t PsiTime::getTime ( void  )

Retrieves the instance's current value in Unix time format.

Returns
The instance's current time as Unix time_t.

Definition at line 132 of file psitime.cc.

◆ getTimeval()

struct timeval & PsiTime::getTimeval ( void  )

Retrieves the instance's current value in Unix time format.

Returns
The instance's current time as Unix struct timeval.

Definition at line 128 of file psitime.cc.

◆ operator<()

bool PsiTime::operator< ( const PsiTime t)

Definition at line 164 of file psitime.cc.

◆ operator=()

PsiTime & PsiTime::operator= ( const PsiTime t)

Assignment operator.

Definition at line 148 of file psitime.cc.

◆ operator==()

bool PsiTime::operator== ( const PsiTime t)

Comparison operators.

Definition at line 158 of file psitime.cc.

◆ operator>()

bool PsiTime::operator> ( const PsiTime t)

Definition at line 172 of file psitime.cc.

◆ psi2unix()

void PsiTime::psi2unix ( void  )
private

Definition at line 253 of file psitime.cc.

◆ setPsiTime() [1/2]

void PsiTime::setPsiTime ( const uint32_t  _ptvHi,
const uint32_t  _ptvLo 
)

Modifies the value of this instance.

Parameters
_ptvHiThe high 32 bits of a Psion time.
_ptvLoThe low 32 bits of a Psion time.

Definition at line 114 of file psitime.cc.

◆ setPsiTime() [2/2]

void PsiTime::setPsiTime ( psi_timeval _ptv)

Modifies the value of this instance.

Parameters
_ptvThe new Psion time representation.

Definition at line 108 of file psitime.cc.

◆ setPsiZone()

void PsiTime::setPsiZone ( psi_timezone _ptz)

Sets the Psion time zone of this instance.

Parameters
_ptzThe new Psion time zone.

Definition at line 120 of file psitime.cc.

◆ setSiboTime()

void PsiTime::setSiboTime ( uint32_t  stime)

Modifies the value of this instance.

Parameters
stimeThe new SIBO time representation.

Definition at line 237 of file psitime.cc.

◆ setUnixNow()

void PsiTime::setUnixNow ( void  )

Sets the value of this instance to the current time of the Unix machine.

Definition at line 102 of file psitime.cc.

◆ setUnixTime() [1/2]

void PsiTime::setUnixTime ( struct timeval *  _utv)

Sets the value of this instance.

Parameters
_utvThe new Unix time representation.

Definition at line 90 of file psitime.cc.

◆ setUnixTime() [2/2]

void PsiTime::setUnixTime ( time_t  time)

Sets the value of this instance.

Parameters
timeThe new Unix time representation.

Definition at line 96 of file psitime.cc.

◆ tryPsiZone()

void PsiTime::tryPsiZone ( )
private

Definition at line 276 of file psitime.cc.

◆ unix2psi()

void PsiTime::unix2psi ( void  )
private

Definition at line 265 of file psitime.cc.

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream s,
const PsiTime t 
)
friend

Prints the instance's value in human readable format.

This function uses the current locale setting for formatting the time.

Parameters
sThe stream to be written.
tThe instance whose value should be displayed.
Returns
The stream.

Definition at line 180 of file psitime.cc.

Member Data Documentation

◆ ptv

psi_timeval PsiTime::ptv
private

Definition at line 309 of file psitime.h.

◆ ptz

psi_timezone PsiTime::ptz
private

Definition at line 310 of file psitime.h.

◆ ptzValid

bool PsiTime::ptzValid
private

Definition at line 313 of file psitime.h.

◆ utv

struct timeval PsiTime::utv
private

Definition at line 311 of file psitime.h.

◆ utz

struct timezone PsiTime::utz
private

Definition at line 312 of file psitime.h.


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