AnCH Framework 0.1
Another C++ Hack Framework
 
Loading...
Searching...
No Matches
anch::date::DateFormatter Class Reference

#include <dateFormatter.hpp>

+ Collaboration diagram for anch::date::DateFormatter:

Public Member Functions

 DateFormatter (const std::string &dateFormat) noexcept
 
virtual ~DateFormatter () noexcept
 
void format (const anch::date::Date &date, std::string &output) const noexcept
 
void format (const anch::date::Date &date, std::ostream &output) const noexcept
 
void parse (const std::string &strDate, anch::date::Date &date) const
 
anch::date::Dateparse (const std::string &strDate) const
 

Static Public Member Functions

static void registerFormatterPart (const std::string &pattern, getInstance instGetter) noexcept
 

Detailed Description

Date string formatter.

Paterns are:

  • %Y: 4 digits year
  • %y: 2 digits year
  • %m: Month (1-12)
  • %d: Day in month (1-31)
  • %H: 00-23 hours
  • %h: 00-11 hours
  • %p: AM/PM marker
  • %M: minutes (00-59)
  • %S: seconds (00-59)
  • %s: milliseconds (000-999)

Do not use characters '%' in your string pattern.

Warning: This class is not thread safe.

Author
Vincent Lachenal

Constructor & Destructor Documentation

◆ DateFormatter()

anch::date::DateFormatter::DateFormatter ( const std::string & dateFormat)
noexcept

DateFormatter constructor

Parameters
dateFormatThe date format

◆ ~DateFormatter()

virtual anch::date::DateFormatter::~DateFormatter ( )
virtualnoexcept

DateFormatter destructor

Member Function Documentation

◆ format() [1/2]

void anch::date::DateFormatter::format ( const anch::date::Date & date,
std::ostream & output ) const
noexcept

Format date

Parameters
dateThe date to format
outputThe output stream
+ Here is the call graph for this function:

◆ format() [2/2]

void anch::date::DateFormatter::format ( const anch::date::Date & date,
std::string & output ) const
noexcept

Format date

Parameters
dateThe date to format
outputThe output string
+ Here is the call graph for this function:

◆ parse() [1/2]

anch::date::Date * anch::date::DateFormatter::parse ( const std::string & strDate) const

Build date from string.
You had to delete Date not to make memory leaks.

Parameters
strDateString formatted date
Returns
A date
Exceptions
InvalidFormatExceptioninvalid format
+ Here is the call graph for this function:

◆ parse() [2/2]

void anch::date::DateFormatter::parse ( const std::string & strDate,
anch::date::Date & date ) const

Build date from string.
You can build the output Date with Date(false) constructor.

Parameters
strDateString formatted date
dateThe output date
Exceptions
InvalidFormatExceptioninvalid format
+ Here is the call graph for this function:

◆ registerFormatterPart()

static void anch::date::DateFormatter::registerFormatterPart ( const std::string & pattern,
getInstance instGetter )
staticnoexcept

Register a new formatter part

Parameters
patternThe formatter part pattern
instGetterThe formatter part new instance getter
+ Here is the call graph for this function:

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