Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class template time_date_t

boost::asn1::time_date_t — ASN1 time template.

Synopsis

template<primitives_t P, typename PolicyT> 
class time_date_t : public boost::asn1::asn_base_t {
public:
  // construct/copy/destruct
  time_date_t();
  time_date_t(const asn_base_ptr &);
  time_date_t(const time_date_t &);
  time_date_t(const ptime &);
  time_date_t& operator=(const time_date_t &);
  time_date_t& operator=(const ptime &);
  ~time_date_t();

  // public member functions
  void assign(const time_date_t &) ;
  void assign(const ptime &) ;
  void assign(const asn_base_t *) ;
  const ptime operator()() ;
  operator ptime() ;
  int getYear() const;
  int getMonth() const;
  int getDay() const;
  int getHour() const;
  int getMinute() const;
  int getSecond() const;
  int getFraction() const;
  int getOffset() const;
  void setYMD(const int, const int, const int) ;
  void setHMS(const int, const int, const int, const int = 0) ;
  void setYear(const int) ;
  void setMonth(const int) ;
  void setDay(const int) ;
  void setHour(const int) ;
  void setMinute(const int) ;
  void setSecond(const int) ;
  void setFraction(const int) ;
  void setOffset(const int) ;
  asn_base_ptr clone() const;
  uint32_t encode(asn_visitor_t &) ;
  uint32_t decode(asn_visitor_t &) ;
  const uint32_t length() ;
  size_t size_of() ;

  // public static functions
  static asn_base_ptr create() ;

  // protected member functions
  void recalc() ;
};

Description

Time-Date

The time and date functionality for ASN1 are supported in Boost.ASN1 through the template class time_date_t. This template has two specializations to for the ASN1 time data types.

UTC utctime_t
GENERALIZED generalizedtime_t

The time_date_t stores it's internal data in a private struct that contains all the relevant pieces of data for time and date management. Access to this data is through member functions for getting/setting pieces of a time-date object.

The main difference between the two times of representations is the amount of data transmitted in their respective values. Generalized times use a full year value as YYYY, where as UTC times only use the last two digits, YY. The time-date template accepts Y2K and non-Y2K years. It will automatically deduce a non-Y2K number and make it Y2K complient.

Assignment between the two time-date types is allowed.

Usage
  utctime_t utcTime;
  
  utcTime.setYMD(8,2,1);
  utcTime.setHMS(13,12,10);
  cout << to_simple_string(utcTime) << endl;

  generalizedtime_t generalTime(utcTime);
  cout << to_simple_string(generalTime) << endl;

time_date_t construct/copy/destruct

  1. time_date_t();
  2. time_date_t(const asn_base_ptr & ptr);

    Copies an time_date_t being pass by an asn_base_ptr.

    Parameters:
    ptr

    asn_base_ptr to copy from

  3. time_date_t(const time_date_t & tt);

    Copies an time_date_t object

    Parameters:
    tt

    A time_date_t object whose content is entirely copied.

  4. time_date_t(const ptime & pt);

    Sets the content from a ptime object

    Parameters:
    pt

    A ptime object whose content is entirely copied.

  5. time_date_t& operator=(const time_date_t & tt);
  6. time_date_t& operator=(const ptime & pt);
  7. ~time_date_t();

time_date_t public member functions

  1. void assign(const time_date_t & tt) ;

    Parameters:
    tt

    A time_date_t object whose content is entirely copied.

  2. void assign(const ptime & pt) ;

    Parameters:
    pt

    A ptime object whose content is entirely copied.

  3. void assign(const asn_base_t * asn_object) ;

    Parameters:
    asn_object

    Value to assign

  4. const ptime operator()() ;
  5. operator ptime() ;
  6. int getYear() const;
  7. int getMonth() const;
  8. int getDay() const;
  9. int getHour() const;
  10. int getMinute() const;
  11. int getSecond() const;
  12. int getFraction() const;
  13. int getOffset() const;
  14. void setYMD(const int y, const int m, const int d) ;

    Parameters:
    d

    Day to set

    m

    Month to set

    y

    Year to set

  15. void setHMS(const int h, const int m, const int s, const int f = 0) ;

    Parameters:
    f

    Fraction of a second to set

    h

    Hour to set

    m

    Minute to set

    s

    Second to set

  16. void setYear(const int y) ;

    Accepts non-Y2k and Y2k values.

    Parameters:
    y

    Year to set.

  17. void setMonth(const int m) ;

    Parameters:
    m

    Month to set

  18. void setDay(const int d) ;

    Parameters:
    d

    Day to set

  19. void setHour(const int h) ;

    Parameters:
    h

    Hour to set

  20. void setMinute(const int m) ;

    Parameters:
    m

    Minute to set

  21. void setSecond(const int s) ;

    Parameters:
    s

    Seconds to set

  22. void setFraction(const int f) ;

    Parameters:
    f

    Fractions of a second to set

  23. void setOffset(const int o) ;

    Parameters:
    o

    Time zone Offset to set

  24. asn_base_ptr clone() const;
  25. uint32_t encode(asn_visitor_t & visitor) ;

    Calls the time_date_t type's policy to encode the data for the time_date_t.

    Parameters:
    visitor

    asn_visitor_t used for the encoding.

    Returns:

    The number of bytes used to encode the time_date_t's data

  26. uint32_t decode(asn_visitor_t & visitor) ;

    Calls the integral type's policy to decode the data for the time_date_t.

    Parameters:
    visitor

    asn_visitor_t used for the decoding.

    Returns:

    The number of bytes used to decode the time_date_t's data

  27. const uint32_t length() ;

    If ASN1 objects have been added since the time this function was called, it will recalculate the length

  28. size_t size_of() ;

    Gets the size of the ASN1 object

    Returns the size of the ASN1 class object sizeof(ASN1)

time_date_t public static functions

  1. static asn_base_ptr create() ;

time_date_t protected member functions

  1. void recalc() ;
Copyright © 2007 Andreas Haberstroh

PrevUpHomeNext