13
0

Replace strftime() with Glib::DateTime()

This is mainly for windows compatibility "%F" is not supported.
An alternative would be to s/%F/%Y-%m-%d/ to produce the ISO date.
This commit is contained in:
Robin Gareus 2020-03-08 23:31:51 +01:00
parent 6f29f45c81
commit 9e2b896516
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 8 additions and 13 deletions

View File

@ -18,6 +18,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <glibmm/datetime.h>
#include "ardour/analyser.h"
#include "ardour/audioengine.h"
#include "ardour/audiofilesource.h"
@ -1262,9 +1264,8 @@ DiskWriter::transport_stopped_wallclock (struct tm& when, time_t twhen, bool abo
as->set_captured_for (_name.val());
as->mark_immutable ();
char buf[128];
strftime (buf, sizeof(buf), "%F %H.%M.%S", &when);
as->set_take_id ( buf );
Glib::DateTime tm (Glib::DateTime::create_now_local (mktime (&when)));
as->set_take_id (tm.format ("%F %H.%M.%S"));
if (Config->get_auto_analyse_audio()) {
Analyser::queue_source_for_analysis (as, true);
@ -1313,9 +1314,8 @@ DiskWriter::transport_stopped_wallclock (struct tm& when, time_t twhen, bool abo
_midi_write_source->set_natural_position (capture_info.front()->start);
_midi_write_source->set_captured_for (_name);
char buf[128];
strftime (buf, sizeof(buf), "%F %H.%M.%S", &when);
_midi_write_source->set_take_id ( buf );
Glib::DateTime tm (Glib::DateTime::create_now_local (mktime (&when)));
_midi_write_source->set_take_id (tm.format ("%F %H.%M.%S"));
/* set length in beats to entire capture length */

View File

@ -649,14 +649,9 @@ void
UI::display_message (const char *prefix, gint /*prefix_len*/, RefPtr<TextBuffer::Tag> ptag, RefPtr<TextBuffer::Tag> mtag, const char *msg)
{
RefPtr<TextBuffer> buffer (errors->text().get_buffer());
Glib::DateTime tm (g_date_time_new_now_local ());
char timebuf[128];
time_t n = time (NULL);
struct tm local_time;
localtime_r (&n, &local_time);
strftime (timebuf, sizeof(timebuf), "%FT%H:%M:%S ", &local_time);
buffer->insert_with_tag(buffer->end(), timebuf, ptag);
buffer->insert_with_tag(buffer->end(), tm.format ("%FT%H:%M:%S "), ptag);
buffer->insert_with_tag(buffer->end(), prefix, ptag);
buffer->insert_with_tag(buffer->end(), msg, mtag);
buffer->insert_with_tag(buffer->end(), "\n", mtag);