Audacity 3.2.0
DateTimeConversions.cpp
Go to the documentation of this file.
1/*!********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file DateTimeConversions.cpp
6 @brief Define functions to work with date and time string representations.
7
8 Dmitry Vedenko
9 **********************************************************************/
10
11#include "DateTimeConversions.h"
12
13#include <wx/datetime.h>
14
15#include "CodeConversions.h"
16
17namespace audacity
18{
19
20bool ParseRFC822Date (const std::string& dateString, SystemTime* time)
21{
22 wxDateTime dt;
23 wxString::const_iterator end;
24
25 if (!dt.ParseRfc822Date (dateString, &end))
26 return false;
27
28 if (time != nullptr)
29 *time = std::chrono::system_clock::from_time_t (dt.GetTicks ());
30
31 return true;
32}
33
34std::string SerializeRFC822Date (SystemTime timePoint)
35{
36 const wxDateTime dt (
37 time_t (std::chrono::duration_cast<std::chrono::seconds> (
38 timePoint.time_since_epoch ()
39 ).count ()));
40
41 return ToUTF8 (dt.Format("%a, %d %b %Y %H:%M:%S %z"));
42}
43
44}
Declare functions to perform UTF-8 to std::wstring conversions.
Declare functions to work with date and time string representations.
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159
std::string ToUTF8(const std::wstring &wstr)
bool ParseRFC822Date(const std::string &dateString, SystemTime *time)
std::string SerializeRFC822Date(SystemTime timePoint)
std::chrono::system_clock::time_point SystemTime