add Space::to_date(...) methods

This commit is contained in:
2023-07-18 18:22:13 +02:00
parent 2c4bfe085b
commit 09215ef5f2
2 changed files with 33 additions and 2 deletions

View File

@@ -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);