add Space::to_date(...) methods
This commit is contained in:
parent
2c4bfe085b
commit
09215ef5f2
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2022, Tomasz Sowa
|
||||
* Copyright (c) 2008-2023, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -1305,6 +1305,19 @@ std::wstring Space::to_wstr() const
|
|||
}
|
||||
|
||||
|
||||
Date Space::to_date() const
|
||||
{
|
||||
if( type == type_wstring )
|
||||
return Date(value.value_wstring);
|
||||
|
||||
if( type == type_string )
|
||||
return Date(value.value_string);
|
||||
|
||||
if( type == type_long )
|
||||
return Date(static_cast<time_t>(value.value_long));
|
||||
|
||||
return Date();
|
||||
}
|
||||
|
||||
|
||||
void Space::to_list(std::list<std::string> & output_list, bool clear_list) const
|
||||
|
@ -1471,6 +1484,20 @@ std::wstring Space::to_wstr(const wchar_t * field, const std::wstring & default_
|
|||
}
|
||||
|
||||
|
||||
Date Space::to_date(const wchar_t * field) const
|
||||
{
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->to_date() : Date();
|
||||
}
|
||||
|
||||
|
||||
Date Space::to_date(const wchar_t * field, const Date & default_value) const
|
||||
{
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->to_date() : default_value;
|
||||
}
|
||||
|
||||
|
||||
bool Space::to_list(const wchar_t * field, std::list<std::string> & output_list, bool clear_list) const
|
||||
{
|
||||
return to_list_generic(field, output_list, clear_list);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2022, Tomasz Sowa
|
||||
* Copyright (c) 2010-2023, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -382,6 +382,7 @@ public:
|
|||
long double to_long_double() const;
|
||||
std::string to_str() const;
|
||||
std::wstring to_wstr() const;
|
||||
Date to_date() const;
|
||||
|
||||
void to_list(std::list<std::string> & output_list, bool clear_list = true) const;
|
||||
void to_list(std::list<std::wstring> & output_list, bool clear_list = true) const;
|
||||
|
@ -410,6 +411,9 @@ public:
|
|||
std::wstring to_wstr(const wchar_t * field, const wchar_t * default_value = nullptr) const;
|
||||
std::wstring to_wstr(const wchar_t * field, const std::wstring & default_value) const;
|
||||
|
||||
Date to_date(const wchar_t * field) const;
|
||||
Date to_date(const wchar_t * field, const Date & default_value) const;
|
||||
|
||||
bool to_list(const wchar_t * field, std::list<std::string> & output_list, bool clear_list = true) const;
|
||||
bool to_list(const wchar_t * field, std::list<std::wstring> & output_list, bool clear_list = true) const;
|
||||
bool to_list(const std::wstring & field, std::list<std::string> & output_list, bool clear_list = true) const;
|
||||
|
|
Loading…
Reference in New Issue