ASN1TTime Class Reference
[Date and Time Runtime Classes]

#include <ASN1TTime.h>

Inheritance diagram for ASN1TTime:
ASN1TGeneralizedTime ASN1TUTCTime

List of all members.

Public Types

enum  {
  January = 1, Jan = 1, February = 2, Feb = 2,
  March = 3, Mar = 3, April = 4, Apr = 4,
  May = 5, June = 6, Jun = 6, July = 7,
  Jul = 7, August = 8, Aug = 8, September = 9,
  Sep = 9, October = 10, Oct = 10, November = 11,
  Nov = 11, December = 12, Dec = 12
}

Public Member Functions

EXTRTMETHOD ASN1TTime ()
EXTRTMETHOD ASN1TTime (OSBOOL useDerRules)
EXTRTMETHOD ASN1TTime (const ASN1TTime &original)
virtual EXTRTMETHOD ~ASN1TTime ()
virtual EXTRTMETHOD int getYear () const
virtual EXTRTMETHOD int getMonth () const
virtual EXTRTMETHOD int getDay () const
virtual EXTRTMETHOD int getHour () const
virtual EXTRTMETHOD int getMinute () const
virtual EXTRTMETHOD int getSecond () const
virtual EXTRTMETHOD int getFraction () const
virtual EXTRTMETHOD double getFractionAsDouble () const
virtual EXTRTMETHOD int getFractionStr (char *const pBuf, size_t bufSize) const
virtual EXTRTMETHOD int getFractionLen () const
virtual EXTRTMETHOD int getDiffHour () const
virtual EXTRTMETHOD int getDiffMinute () const
virtual EXTRTMETHOD int getDiff () const
virtual EXTRTMETHOD OSBOOL getUTC () const
virtual EXTRTMETHOD time_t getTime () const
void setDER (OSBOOL bvalue)
virtual EXTRTMETHOD int setUTC (OSBOOL utc)
virtual EXTRTMETHOD int setYear (short year_)
virtual EXTRTMETHOD int setMonth (short month_)
virtual EXTRTMETHOD int setDay (short day_)
virtual EXTRTMETHOD int setHour (short hour_)
virtual EXTRTMETHOD int setMinute (short minute_)
virtual EXTRTMETHOD int setSecond (short second_)
virtual EXTRTMETHOD int setFraction (int fraction, int fracLen=-1)
virtual EXTRTMETHOD int setFraction (double frac, int fracLen)
virtual EXTRTMETHOD int setFraction (char const *frac)
virtual int setTime (time_t time, OSBOOL diffTime)=0
virtual EXTRTMETHOD int setDiffHour (short dhour)
virtual EXTRTMETHOD int setDiff (short dhour, short dminute)
virtual EXTRTMETHOD int setDiff (short inMinutes)
virtual int parseString (const char *string)=0
virtual EXTRTMETHOD void clear ()
virtual int compileString (char *pbuf, size_t bufsize) const =0
virtual EXTRTMETHOD int equals (const ASN1TTime &) const
EXTRTMETHOD const char * toString (char *pbuf, size_t bufsize) const
EXTRTMETHOD const char * toString (OSCTXT *pctxt) const
EXTRTMETHOD const char * toString () const
EXTRTMETHOD const ASN1TTimeoperator= (const ASN1TTime &)
virtual EXTRTMETHOD OSBOOL operator== (const ASN1TTime &) const
virtual EXTRTMETHOD OSBOOL operator!= (const ASN1TTime &) const
virtual EXTRTMETHOD OSBOOL operator> (const ASN1TTime &) const
virtual EXTRTMETHOD OSBOOL operator< (const ASN1TTime &) const
virtual EXTRTMETHOD OSBOOL operator>= (const ASN1TTime &) const
virtual EXTRTMETHOD OSBOOL operator<= (const ASN1TTime &) const

Public Attributes

short mYear
short mMonth
short mDay
short mHour
short mMinute
short mSecond
short mDiffHour
short mDiffMin
int mSecFraction
int mSecFracLen
int mStatus
OSBOOL mbUtcFlag
OSBOOL mbDerRules

Protected Member Functions

EXTRTMETHOD void privateInit ()
EXTRTMETHOD int getDaysNum () const
EXTRTMETHOD long getMillisNum () const

Static Protected Member Functions

static EXTRTMETHOD int checkDate (int day, int month, int year)
static EXTRTMETHOD void addMilliseconds (int deltaMs, short &year, short &month, short &day, short &hour, short &minute, short &second, int &secFraction, int secFracLen)
static EXTRTMETHOD void addDays (int deltaDays, short &year, short &month, short &day)
static EXTRTMETHOD short daysInMonth (int i)
static EXTRTMETHOD int daysAfterMonth (int i)

Detailed Description

ASN.1 Time utility base class.


Constructor & Destructor Documentation

EXTRTMETHOD ASN1TTime::ASN1TTime (  ) 

This constructpor creates an empty time class.

EXTRTMETHOD ASN1TTime::ASN1TTime ( OSBOOL  useDerRules  ) 

This constructor creates an empty time class.

Parameters:
useDerRules Use the Distinguished Encoding Rules (DER) to operate on this time value.
EXTRTMETHOD ASN1TTime::ASN1TTime ( const ASN1TTime original  ) 

The copy constructor.

Parameters:
original The original time string object value.
virtual EXTRTMETHOD ASN1TTime::~ASN1TTime (  )  [virtual]

The destructor.


Member Function Documentation

virtual EXTRTMETHOD void ASN1TTime::clear (  )  [virtual]

This method clears the time object.

Note the action of this method may differ for different inherited ASN1TTime classes.

Reimplemented in ASN1TUTCTime.

virtual int ASN1TTime::compileString ( char *  pbuf,
size_t  bufsize 
) const [pure virtual]

Compiles new time string accoring X.680 and ISO 8601. Returns 0, if succeed, or error code, if error.

Parameters:
pbuf A pointer to destination buffer.
bufsize A size of destination buffer.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.

Implemented in ASN1TGeneralizedTime, and ASN1TUTCTime.

virtual EXTRTMETHOD int ASN1TTime::equals ( const ASN1TTime  )  const [virtual]

This method compares times.

virtual EXTRTMETHOD int ASN1TTime::getDay (  )  const [virtual]

This method returns the day of month number component of the time value.

The number of the first day in the month is 1; the number of the last day may be in the interval from 28 to 31. Note that the return value may be differ for different inherited ASN1TTime classes.

Returns:
Day of month component (1 - 31) is returned if the operation is successful. If the operation fails, a negative value is returned.
virtual EXTRTMETHOD int ASN1TTime::getDiff (  )  const [virtual]

This method returns the difference between the time zone of the object and the Coordinated Universal Time (UTC).

The UTC time is the sum of the local time and a positive of negative time difference. Note that the return value may differ for different inherited ASN1TTime classes.

Returns:
The negative or positive minute component of the difference between the time zone of the object and the UTC time (-12*60 - +12*60) is returned if the operation is successful. If the operation fails, a negative value is returned.
virtual EXTRTMETHOD int ASN1TTime::getDiffHour (  )  const [virtual]

This method returns the hour component of the difference between the time zone of the object and the Coordinated Universal Time (UTC).

The UTC time is the sum of the local time and a positive of negative time difference. Note that the return value may differ for different inherited ASN1TTime classes.

Returns:
The negative or positive hour component of the difference between the time zone of the object and the UTC time (-12 - +12) is returned if the operation is successful. If the operation fails, a negative value is returned.
virtual EXTRTMETHOD int ASN1TTime::getDiffMinute (  )  const [virtual]

This method returns the minute component of the difference between the time zone of the object and the Coordinated Universal Time (UTC).

The UTC time is the sum of the local time and a positive of negative time difference. Note that the return value may differ for different inherited ASN1TTime classes.

Returns:
The negative or positive minute component of the difference between the time zone of the object and the UTC time (-59 - +59) is returned if the operation is successful. If the operation fails, a negative value is returned.
virtual EXTRTMETHOD int ASN1TTime::getFraction (  )  const [virtual]

This method returns the second's decimal component of the time value.

Second's decimal fraction is represented by one or more digits from 0 to 9.

Returns:
Second's decimal fraction component is returned if operation is successful. If the operation fails, a negative value is returned.

Reimplemented in ASN1TUTCTime.

virtual EXTRTMETHOD double ASN1TTime::getFractionAsDouble (  )  const [virtual]

This method returns the second's decimal component of the time value. Second's fraction will be represented as double value more than 0 and less than 1.

Second's decimal fraction is represented by one or more digits from 0 to 9.

Returns:
Second's decimal fraction component is returned if operation is successful. If the operation fails, a negative value is returned.
virtual EXTRTMETHOD int ASN1TTime::getFractionLen (  )  const [virtual]

This method returns the number of digits in second's decimal component of the time value.

Returns:
Second's decimal fraction's length is returned if operation is successful. If the operation fails, a negative value is returned.
virtual EXTRTMETHOD int ASN1TTime::getFractionStr ( char *const   pBuf,
size_t  bufSize 
) const [virtual]

This method returns the second's decimal component of the time value. Second's fraction will be represented as string w/o integer part and decimal point.

Returns:
Length of the fraction string returned in pBuf, if operation is successful. If the operation fails, a negative value is returned.
virtual EXTRTMETHOD int ASN1TTime::getHour (  )  const [virtual]

This method returns the hour component of the time value.

As the ISO 8601 is based on the 24-hour timekeeping system, hours are represented by two-digit values from 00 to 23. Note that the return value may differ from different inherited ASN1TTime classes.

Returns:
Hour component (0 - 23) is returned if the operation is successful. If the operation fails, a negative value is returned.
virtual EXTRTMETHOD int ASN1TTime::getMinute (  )  const [virtual]

This method returns the minute component of the time value.

Minutes are represented by the two digits from 00 to 59. Note that the return value may differ from different inherited ASN1TTime classes.

Returns:
Minute component (0 - 59) is returned if the operation is successful. If the operation fails, a negative value is returned.
virtual EXTRTMETHOD int ASN1TTime::getMonth (  )  const [virtual]

This method returns the month number component of the time value.

The number of January is 1, February 2, ... up to December 12. You may also use enumerated valued for decoded months: ASN1TTime::January, ASN1TTime::February, etc. Also short aliases for months can be used: ASN1TTime::Jan, ASN1TTime::Feb, etc. Note that the return value may differ for different inherited ASN1TTime classes.

Returns:
Month component (1 - 12) is returned if operation is successful. If the operation fails, a negative value is returned.
virtual EXTRTMETHOD int ASN1TTime::getSecond (  )  const [virtual]

This method returns the second component of the time value.

Seconds are represented by two digits from 00 to 59. Note that the return value may differ from different inherited ASN1TTime classes.

Returns:
Second component (0 - 59) is returned if the operation is successful. If the operation fails, a negative value is returned.
virtual EXTRTMETHOD time_t ASN1TTime::getTime (  )  const [virtual]

This method converts the time string to a value of the built-in C type time_t.

The value is the number of seconds from January 1, 1970. If the time is represned as UTC time plus or minus a time difference, then the resulting value will be recalculated as local time. For example, if the time string is "19991208120000+0930", then this string will be converted to "19991208213000" and then converted to a time_t value. Note that the return value may differ for different inherited ASN1TTime classes.

Returns:
The time value, expressed as a number of seconds from January 1, 1970. If the operation fails, a negative value is returned.
virtual EXTRTMETHOD OSBOOL ASN1TTime::getUTC (  )  const [virtual]

This method returns the UTC flag state.

If the UTC flag is TRUE, then the time is a UTC time and symbol Z is added at the end of the time string. Otherwise, it is local time.

Returns:
UTC flag state is returned.
virtual EXTRTMETHOD int ASN1TTime::getYear (  )  const [virtual]

This method returns the year component of the time value.

Note that the return value may differ for different inherited ASN1TTime classes.

Returns:
Year component (full 4 digits) is returned if the operation is successful. If the operation fails, a negative value is returned.
virtual int ASN1TTime::parseString ( const char *  string  )  [pure virtual]

This method parses the given time string.

The string is expected to be in the ASN.1 value notation format for the given ASN.1 time string type. Note that the action of this method may differ for different inherited ASN1TTime classes.

Parameters:
string The time string value to be parsed.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.

Implemented in ASN1TGeneralizedTime, and ASN1TUTCTime.

virtual EXTRTMETHOD int ASN1TTime::setDay ( short  day_  )  [virtual]

This method sets the day of month number component of the time value.

The number of the first day in the month is 1; the number of the last day in the month may be in the interval from 28 to 31. Note that the action of this method may differ for different inherited ASN1TTime classes.

Parameters:
day_ Day of month component (1 - 31).
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
void ASN1TTime::setDER ( OSBOOL  bvalue  )  [inline]

This method sets the 'use DER' flag which enforces the DER rules when time strings are constructed or parsed.

virtual EXTRTMETHOD int ASN1TTime::setDiff ( short  inMinutes  )  [virtual]

This method sets the difference between the time zone of the object and Coordinated Universal Time (UTC), in minutes.

The UTC time is the sum of the local time and a positive or negative time difference. Note that the action of this method may differ for different inherited ASN1TTime classes.

Parameters:
inMinutes The negative or positive difference, in minutes, between the time zone of the object and the UTC time (-12*60 - +12*60) is returned if the operation is successful.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
virtual EXTRTMETHOD int ASN1TTime::setDiff ( short  dhour,
short  dminute 
) [virtual]

This method sets the hours and the minute components of the difference between the time zone of the object and Coordinated Universal Time (UTC).

The UTC time is the sum of the local time and a positive or negative time difference. Note that the action of this method may differ for different inherited ASN1TTime classes.

Parameters:
dhour The negative or positive hour component of the difference between the time zone of the object and the UTC time (-12 - +12).
dminute The negative or positive minute component of the difference between the time zone of the object and the UTC time (-59 - +59).
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
virtual EXTRTMETHOD int ASN1TTime::setDiffHour ( short  dhour  )  [virtual]

This method sets teh hour component of the difference between the time zone of the object and the Coordinated Universal Time (UTC).

The UTC time is the sum of the local time and a positive or negative time difference. Note that the action of this method may differ from different inherited ASN1TTime classes.

Parameters:
dhour The negative or positive hour component of the difference between the time zone of the object and the UTC time (-12 - +12) is returned if the operation is successful. If the operation fails, a negative value is returned.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
virtual EXTRTMETHOD int ASN1TTime::setFraction ( char const *  frac  )  [virtual]

This method sets the second's decimal fraction component of the time value. Double value must be greater or equal 0 and less than 1.

Parameters:
frac Second's decimal fraction component.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.
virtual EXTRTMETHOD int ASN1TTime::setFraction ( double  frac,
int  fracLen 
) [virtual]

This method sets the second's decimal fraction component of the time value. Double value must be greater or equal 0 and less than 1.

Parameters:
frac Second's decimal fraction component.
fracLen Specifies number of digits in second's fraction.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
virtual EXTRTMETHOD int ASN1TTime::setFraction ( int  fraction,
int  fracLen = -1 
) [virtual]

This method sets the second's decimal fraction component of the time value.

Second's decimal fraction is represented by one or more digits from 0 to 9. Note that the action of this method may differ for different inherited ASN1TTime classes.

Parameters:
fraction Second's decimal fraction component (0 - 9).
fracLen Optional parameter specifies number of digits in second's fraction.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

Reimplemented in ASN1TUTCTime.

virtual EXTRTMETHOD int ASN1TTime::setHour ( short  hour_  )  [virtual]

This method sets the hour component of the time value.

As the ISO 8601 is based on the 24-hour timekeeping system, hours are represented by two digits from 00 to 23. Note that the action of this method may differ for different inherited ASN1TTime classes.

Parameters:
hour_ Hour component (0 - 23).
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
virtual EXTRTMETHOD int ASN1TTime::setMinute ( short  minute_  )  [virtual]

This method sets the minute component of the time value.

Minutes are represented by two digits from 00 to 59. Note that the action of this method may differ for different inherited ASN1TTime classes.

Parameters:
minute_ Minute component (0 - 59).
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
virtual EXTRTMETHOD int ASN1TTime::setMonth ( short  month_  )  [virtual]

This method sets the month number component of the time value.

The number of January is 1, February 2, ..., through December 12. You may use enumerated values for months encoding: ASN1TTime::January, ASN1TTime::February, etc. Also you can use short aliases for months: ASN1TTime::Jan, ASN1TTime::Feb, etc. Note that the action of this method may differ for different inherited ASN1TTime classes.

Parameters:
month_ Month component (1 - 12).
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
virtual EXTRTMETHOD int ASN1TTime::setSecond ( short  second_  )  [virtual]

This method sets the second component of the time value.

Seconds are represented by two digits from 00 to 59. Note that the action of this method may differ form different inherited ASN1TTime classes.

Parameters:
second_ Second component (0 - 59).
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
virtual int ASN1TTime::setTime ( time_t  time,
OSBOOL  diffTime 
) [pure virtual]

This converts the value of the C built-in type time_t to a time string.

The value is the number of seconds from January 1, 1970. Note that the action of this method may differ for different inherited ASN1TTime Classes.

Parameters:
time The time value, expressed as a number of seconds from January 1, 1970.
diffTime TRUE means the difference between local time and UTC time will be calculated; in other case, only local time will be stored.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.

Implemented in ASN1TGeneralizedTime, and ASN1TUTCTime.

virtual EXTRTMETHOD int ASN1TTime::setUTC ( OSBOOL  utc  )  [virtual]

This method sets teh UTC flag state.

If the UTC flag is TRUE, then the time is a UTC time and symbol 'Z' is added to the end of the string. Otherwise, it is a local time.

Parameters:
utc UTC flag state.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.

Reimplemented in ASN1TUTCTime.

virtual EXTRTMETHOD int ASN1TTime::setYear ( short  year_  )  [virtual]

This method sets the year component of the time value.

Note that the action of this method may differ for different inherited ASN1TTime classes.

Parameters:
year_ Year component (full 4 digits).
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.

Reimplemented in ASN1TUTCTime.

EXTRTMETHOD const char* ASN1TTime::toString (  )  const

Get a printable ASCII string of the time value. Memory will be allocated using new[] operator. User is responsible to free it using delete[].

Returns:
Compiled time string. NULL, if error occurs.
EXTRTMETHOD const char* ASN1TTime::toString ( OSCTXT pctxt  )  const

Get a printable ASCII string of the time value.

Parameters:
pctxt Pointer to a context structure.
Returns:
Compiled time string. NULL, if error occurs.
EXTRTMETHOD const char* ASN1TTime::toString ( char *  pbuf,
size_t  bufsize 
) const

Get a printable ASCII string of the time value into the specified buffer.

Parameters:
pbuf Pointer to a destination buffer.
bufsize Size of destination buffer.
Returns:
Compiled time string. NULL, if error occurs.

Member Data Documentation

This member variable tells whether we will encode this time according to the Distinguished Encoding Rules (DER) or not.

This member variable tells whether this time is UTC time or not.

This member variable holds this time's day.

This member variable holds this time's hour differential.

This member variable holds this time's minute differential.

This member variable holds this time's hour.

This member variable holds this time's minute.

This member variable holds this time's month.

This member variable holds this time's fractional seconds length.

This member variable holds this time's fractional seconds.

This member variable holds this time's second.

This member variable holds this time's status.

This member variable holds this time's year.


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