libcryptosec
Classes | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members

Implementa a representação da data. É utilizada em certificados, LCRs. Utiliza o formato epoch (time_t) para representar datas internamente. More...

#include <DateTime.h>

Classes

struct  DateVal
 

Public Member Functions

 DateTime () throw (BigIntegerException)
 
 DateTime (time_t dateTime) throw (BigIntegerException)
 
 DateTime (BigInteger const &dateTime) throw (BigIntegerException)
 
 DateTime (ASN1_TIME *asn1Time) throw (BigIntegerException)
 
 DateTime (std::string utc) throw (BigIntegerException)
 
virtual ~DateTime ()
 
std::string getXmlEncoded (std::string tab="") const throw (BigIntegerException)
 
void setDateTime (time_t dateTime) throw (BigIntegerException)
 
void setDateTime (BigInteger const &dateTime) throw (BigIntegerException)
 
time_t getDateTime () const throw (BigIntegerException)
 
BigInteger const & getSeconds () const throw ()
 
ASN1_TIME * getAsn1Time () const throw (BigIntegerException)
 
ASN1_TIME * getGeneralizedTime () const throw (BigIntegerException)
 
ASN1_TIME * getUTCTime () const throw (BigIntegerException)
 
std::string getISODate () const throw (BigIntegerException)
 
DateTimeoperator= (const DateTime &value) throw (BigIntegerException)
 
void addSeconds (long b) throw (BigIntegerException)
 
void addMinutes (long b) throw (BigIntegerException)
 
void addHours (long b) throw (BigIntegerException)
 
void addDays (long b) throw (BigIntegerException)
 
void addYears (long b) throw (BigIntegerException)
 
bool operator== (const DateTime &other) const throw ()
 
bool operator== (time_t other) const throw (BigIntegerException)
 
bool operator< (const DateTime &other) const throw ()
 
bool operator< (time_t other) const throw (BigIntegerException)
 
bool operator> (const DateTime &other) const throw ()
 
bool operator> (time_t other) const throw (BigIntegerException)
 

Static Public Member Functions

static DateTime::DateVal getDate (BigInteger const &epoch) throw (BigIntegerException)
 
static BigInteger date2epoch (string aString) throw (BigIntegerException)
 
static BigInteger date2epoch (int year, int month, int day, int hour, int min, int sec) throw (BigIntegerException)
 
static int getDayOfWeek (int year, int month, int day) throw ()
 
static bool isLeapYear (int y) throw ()
 
static int getYearSize (int year)
 
static int getMonthSize (int month, int year)
 

Protected Attributes

BigInteger seconds
 

Detailed Description

Implementa a representação da data. É utilizada em certificados, LCRs. Utiliza o formato epoch (time_t) para representar datas internamente.

Constructor & Destructor Documentation

◆ DateTime() [1/5]

DateTime::DateTime ( )
throw (BigIntegerException
)

Construtor padrão. Cria um objeto DateTime com data 0 (00:00:00 UTC, 1 de Janeiro de 1970).

◆ DateTime() [2/5]

DateTime::DateTime ( time_t  dateTime)
throw (BigIntegerException
)

Construtor. Cria um objeto DateTime com uma data específica.

Parameters
dateTimedata específica em segundos. obs: linux: time_t = __SLONGWORD_TYPE = long int = long.

◆ DateTime() [3/5]

DateTime::DateTime ( BigInteger const &  dateTime)
throw (BigIntegerException
)

Construtor. Cria um objeto DateTime com uma data específica.

Parameters
dateTimedata específica em segundos.

◆ DateTime() [4/5]

DateTime::DateTime ( ASN1_TIME *  asn1Time)
throw (BigIntegerException
)

Contrutor. Cria um objeto DateTime com uma data específica.

Parameters
asn1Timedata específica.

◆ DateTime() [5/5]

DateTime::DateTime ( std::string  utc)
throw (BigIntegerException
)

Contrutor. Cria um objeto DateTime com uma data específica.

Parameters
utcstring no formato UTCTime(YYMMDDHHMMSSZ) ou GeneralizedTime (YYYYMMDDHHMMSSZ). Notar que ambos estão no fuso Zulu (GMT+0).

◆ ~DateTime()

DateTime::~DateTime ( )
virtual

Destrutor.

Member Function Documentation

◆ addDays()

void DateTime::addDays ( long  b)
throw (BigIntegerException
)

Adiciona dias.

Parameters
quantidadede dias.

◆ addHours()

void DateTime::addHours ( long  b)
throw (BigIntegerException
)

Adiciona horas.

Parameters
quantidadede horas.

◆ addMinutes()

void DateTime::addMinutes ( long  b)
throw (BigIntegerException
)

Adiciona minutos.

Parameters
quantidadede minutos.

◆ addSeconds()

void DateTime::addSeconds ( long  b)
throw (BigIntegerException
)

Adiciona segundos.

Parameters
quantidadede segundos.

◆ addYears()

void DateTime::addYears ( long  b)
throw (BigIntegerException
)

Adiciona anos.

Parameters
quantidadede anos.

◆ date2epoch() [1/2]

static BigInteger DateTime::date2epoch ( string  aString)
throw (BigIntegerException
)
inlinestatic

Transforma de formato UTCTime(YYMMDDHHMMSSZ) ou GeneralizedTime (YYYYMMDDHHMMSSZ) para epoch(segundos).

Parameters
aStringstring no formato 'YYMMDDHHMMSSZ' ou 'YYYYMMDDHHMMSSZ'. return segundos.

◆ date2epoch() [2/2]

static BigInteger DateTime::date2epoch ( int  year,
int  month,
int  day,
int  hour,
int  min,
int  sec 
)
throw (BigIntegerException
)
inlinestatic

Transforma do formato ano, mês [0-11], dia [1-31], hora [0-23], minuto [0-59] e segundo 0-59 para epoch.

Returns
segundos.

◆ getAsn1Time()

ASN1_TIME * DateTime::getAsn1Time ( ) const
throw (BigIntegerException
)

Obtem data em formato ASN1.

Returns
objeto ASN1_TIME no formato UTCTime se ano inferior a 2050, GeneralizedTime caso contrario.

◆ getDate()

static DateTime::DateVal DateTime::getDate ( BigInteger const &  epoch)
throw (BigIntegerException
)
inlinestatic

Transforma do formato em segundos (epoch) para ano, mês, dia, hora, minuto e segundo.

Parameters
epochreferência para segundos.
Returns
estrutura com ano, mês, dia, hora, minuto e segundo.

◆ getDateTime()

time_t DateTime::getDateTime ( ) const
throw (BigIntegerException
)

Obtem data em segundos.

Returns
data em segundos.

◆ getDayOfWeek()

static int DateTime::getDayOfWeek ( int  year,
int  month,
int  day 
)
throw (
)
inlinestatic

◆ getGeneralizedTime()

ASN1_TIME * DateTime::getGeneralizedTime ( ) const
throw (BigIntegerException
)

Obtem data em formato ASN1.

Returns
objeto ASN1_TIME no formato GeneralizedTime (YYYYMMDDHHMMSSZ).

◆ getISODate()

std::string DateTime::getISODate ( ) const
throw (BigIntegerException
)

Obtem data em formato ISO8601.

Returns
string no formato YYYY-MM-DDTHH:MM:SS (no GMT).

◆ getMonthSize()

static int DateTime::getMonthSize ( int  month,
int  year 
)
inlinestatic

Retorna quantidade de dias de um ano

Parameters
monthmês [0-11]
yearano desejado.
Returns
número de dias.

◆ getSeconds()

BigInteger const & DateTime::getSeconds ( ) const
throw (
)

Obtem data em segundos.

Returns
data em segundos.

◆ getUTCTime()

ASN1_TIME * DateTime::getUTCTime ( ) const
throw (BigIntegerException
)

Obtem data em formato ASN1.

Returns
objeto ASN1_TIME no formato UTCTime (YYMMDDHHMMSSZ).

◆ getXmlEncoded()

std::string DateTime::getXmlEncoded ( std::string  tab = "") const
throw (BigIntegerException
)

Obtem representação da data em formato Xml

Returns
data em formato Xml

◆ getYearSize()

static int DateTime::getYearSize ( int  year)
inlinestatic

Retorna quantidade de dias de um ano

Parameters
yearano desejado.
Returns
número de dias.

◆ isLeapYear()

static bool DateTime::isLeapYear ( int  y)
throw (
)
inlinestatic

Retorna dia da semana de referência (doomsday) para um ano específico.

Parameters
yearano.
Returns
dia da semana: 0 para Domingo, 6 para Sábado. Verifica se um ano é bissexto.
Parameters
yano.
Returns
true se é bissexto, false caso contrário.

◆ operator<() [1/2]

bool DateTime::operator< ( const DateTime other) const
throw (
)

◆ operator<() [2/2]

bool DateTime::operator< ( time_t  other) const
throw (BigIntegerException
)

◆ operator=()

DateTime & DateTime::operator= ( const DateTime value)
throw (BigIntegerException
)

Operador de atribuição.

Parameters
valuereferência para objeto DateTime.

◆ operator==() [1/2]

bool DateTime::operator== ( const DateTime other) const
throw (
)

◆ operator==() [2/2]

bool DateTime::operator== ( time_t  other) const
throw (BigIntegerException
)

◆ operator>() [1/2]

bool DateTime::operator> ( const DateTime other) const
throw (
)

◆ operator>() [2/2]

bool DateTime::operator> ( time_t  other) const
throw (BigIntegerException
)

◆ setDateTime() [1/2]

void DateTime::setDateTime ( time_t  dateTime)
throw (BigIntegerException
)

Define a data do objeto DateTime.

Parameters
dateTimedata específica em segundos.

◆ setDateTime() [2/2]

void DateTime::setDateTime ( BigInteger const &  dateTime)
throw (BigIntegerException
)

Define a data do objeto DateTime.

Parameters
dateTimedata específica em segundos.

Member Data Documentation

◆ seconds

BigInteger DateTime::seconds
protected

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