diff --git a/common/string_utils.cpp b/common/string_utils.cpp index 7588ee0a9f..6934321fa7 100644 --- a/common/string_utils.cpp +++ b/common/string_utils.cpp @@ -32,6 +32,7 @@ #include #include // StrPrintf #include +#include /** @@ -660,12 +661,10 @@ char* GetLine( FILE* File, char* Line, int* LineNum, int SizeLine ) } -wxString DateAndTime() +wxString GetISO8601CurrentDateTime() { - wxDateTime datetime = wxDateTime::Now(); - - datetime.SetCountry( wxDateTime::Country_Default ); - return datetime.Format( wxDefaultDateTimeFormat, wxDateTime::Local ); + std::string str = fmt::format( "{:%FT%T%z}", fmt::localtime( std::time( nullptr ) ) ); + return FROM_UTF8( str.c_str() ); } diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp index 8b8d51019b..e8ea48bb69 100644 --- a/eeschema/dialogs/dialog_erc.cpp +++ b/eeschema/dialogs/dialog_erc.cpp @@ -998,7 +998,7 @@ bool DIALOG_ERC::writeReport( const wxString& aFullFileName ) if( !file.IsOpened() ) return false; - wxString msg = wxString::Format( _( "ERC report (%s, Encoding UTF8)\n" ), DateAndTime() ); + wxString msg = wxString::Format( _( "ERC report (%s, Encoding UTF8)\n" ), GetISO8601CurrentDateTime() ); std::map itemMap; diff --git a/eeschema/netlist_exporters/netlist_exporter_allegro.cpp b/eeschema/netlist_exporters/netlist_exporter_allegro.cpp index 581f0b9cff..222492eead 100644 --- a/eeschema/netlist_exporters/netlist_exporter_allegro.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_allegro.cpp @@ -68,7 +68,7 @@ bool NETLIST_EXPORTER_ALLEGRO::WriteNetlist( const wxString& aOutFileName, } ret |= fprintf( m_f, "(Source: %s)\n", TO_UTF8( m_schematic->GetFileName() ) ); - ret |= fprintf( m_f, "(Date: %s)\n", TO_UTF8( DateAndTime() ) ); + ret |= fprintf( m_f, "(Date: %s)\n", TO_UTF8( GetISO8601CurrentDateTime() ) ); m_packageProperties.clear(); m_componentGroups.clear(); diff --git a/eeschema/netlist_exporters/netlist_exporter_cadstar.cpp b/eeschema/netlist_exporters/netlist_exporter_cadstar.cpp index 541f0a5aac..8321386085 100644 --- a/eeschema/netlist_exporters/netlist_exporter_cadstar.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_cadstar.cpp @@ -57,7 +57,7 @@ bool NETLIST_EXPORTER_CADSTAR::WriteNetlist( const wxString& aOutFileName, wxString title = wxT( "Eeschema " ) + GetBuildVersion(); ret |= fprintf( f, "%sHEA\n", TO_UTF8( StartLine ) ); - ret |= fprintf( f, "%sTIM %s\n", TO_UTF8( StartLine ), TO_UTF8( DateAndTime() ) ); + ret |= fprintf( f, "%sTIM %s\n", TO_UTF8( StartLine ), TO_UTF8( GetISO8601CurrentDateTime() ) ); ret |= fprintf( f, "%sAPP ", TO_UTF8( StartLine ) ); ret |= fprintf( f, "\"%s\"\n", TO_UTF8( title ) ); ret |= fprintf( f, ".TYP FULL\n\n" ); diff --git a/eeschema/netlist_exporters/netlist_exporter_orcadpcb2.cpp b/eeschema/netlist_exporters/netlist_exporter_orcadpcb2.cpp index 33a1948130..7b58ca204b 100644 --- a/eeschema/netlist_exporters/netlist_exporter_orcadpcb2.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_orcadpcb2.cpp @@ -57,7 +57,7 @@ bool NETLIST_EXPORTER_ORCADPCB2::WriteNetlist( const wxString& aOutFileName, std::vector< SCH_REFERENCE > cmpList; ret |= fprintf( f, "( { %s created %s }\n", - NETLIST_HEAD_STRING, TO_UTF8( DateAndTime() ) ); + NETLIST_HEAD_STRING, TO_UTF8( GetISO8601CurrentDateTime() ) ); // Create netlist footprints section m_referencesAlreadyFound.Clear(); diff --git a/eeschema/netlist_exporters/netlist_exporter_xml.cpp b/eeschema/netlist_exporters/netlist_exporter_xml.cpp index eeb9a18abf..0d2584e75e 100644 --- a/eeschema/netlist_exporters/netlist_exporter_xml.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_xml.cpp @@ -419,7 +419,7 @@ XNODE* NETLIST_EXPORTER_XML::makeDesignHeader() // the root sheet is a special sheet, call it source xdesign->AddChild( node( wxT( "source" ), m_schematic->GetFileName() ) ); - xdesign->AddChild( node( wxT( "date" ), DateAndTime() ) ); + xdesign->AddChild( node( wxT( "date" ), GetISO8601CurrentDateTime() ) ); // which Eeschema tool xdesign->AddChild( node( wxT( "tool" ), wxT( "Eeschema " ) + GetBuildVersion() ) ); diff --git a/include/string_utils.h b/include/string_utils.h index 664649addc..84e9c69cdc 100644 --- a/include/string_utils.h +++ b/include/string_utils.h @@ -153,7 +153,7 @@ char* StrPurge( char* text ); /** * @return a string giving the current date and time. */ -wxString DateAndTime(); +wxString GetISO8601CurrentDateTime(); /** * Compare two strings with alphanumerical content. diff --git a/pcb_calculator/datafile_read_write.cpp b/pcb_calculator/datafile_read_write.cpp index dd161126c8..d8e972b51e 100644 --- a/pcb_calculator/datafile_read_write.cpp +++ b/pcb_calculator/datafile_read_write.cpp @@ -135,7 +135,7 @@ int PCB_CALCULATOR_DATAFILE::WriteHeader( OUTPUTFORMATTER* aFormatter ) const aFormatter->Print( nestlevel++, "(datafile\n"); aFormatter->Print( nestlevel++, "(version 1)\n" ); aFormatter->Print( nestlevel++, "(date %s)\n", - aFormatter->Quotew( DateAndTime() ).c_str() ); + aFormatter->Quotew( GetISO8601CurrentDateTime() ).c_str() ); aFormatter->Print( nestlevel++, "(tool %s)\n", aFormatter->Quotew( Pgm().App().GetAppName() + wxChar(' ') + GetBuildVersion() ).c_str() ); diff --git a/pcbnew/exporters/export_footprint_associations.cpp b/pcbnew/exporters/export_footprint_associations.cpp index 48e45aab57..af8c5270d9 100644 --- a/pcbnew/exporters/export_footprint_associations.cpp +++ b/pcbnew/exporters/export_footprint_associations.cpp @@ -40,7 +40,7 @@ bool RecreateCmpFile( BOARD * aBrd, const wxString& aFullCmpFileName ) if( cmpFile == nullptr ) return false; - fprintf( cmpFile, "Cmp-Mod V01 Created by PcbNew date = %s\n", TO_UTF8( DateAndTime() ) ); + fprintf( cmpFile, "Cmp-Mod V01 Created by PcbNew date = %s\n", TO_UTF8( GetISO8601CurrentDateTime() ) ); for( FOOTPRINT* fp : aBrd->Footprints() ) { diff --git a/pcbnew/exporters/gen_drill_report_files.cpp b/pcbnew/exporters/gen_drill_report_files.cpp index 940832b172..477683c86d 100644 --- a/pcbnew/exporters/gen_drill_report_files.cpp +++ b/pcbnew/exporters/gen_drill_report_files.cpp @@ -369,7 +369,7 @@ bool GENDRILL_WRITER_BASE::GenDrillReportFile( const wxString& aFullFileName ) std::vector hole_sets = getUniqueLayerPairs(); out.Print( 0, "Drill report for %s\n", TO_UTF8( brdFilename.GetFullName() ) ); - out.Print( 0, "Created on %s\n\n", TO_UTF8( DateAndTime() ) ); + out.Print( 0, "Created on %s\n\n", TO_UTF8( GetISO8601CurrentDateTime() ) ); // Output the cu layer stackup, so layer name references make sense. out.Print( 0, "Copper Layer Stackup:\n" ); diff --git a/pcbnew/exporters/gendrill_Excellon_writer.cpp b/pcbnew/exporters/gendrill_Excellon_writer.cpp index 5d3b820575..3db1ae6541 100644 --- a/pcbnew/exporters/gendrill_Excellon_writer.cpp +++ b/pcbnew/exporters/gendrill_Excellon_writer.cpp @@ -497,7 +497,7 @@ void EXCELLON_WRITER::writeEXCELLONHeader( DRILL_LAYER_PAIR aLayerPair, TYPE_FIL wxString msg; msg << wxT( "KiCad " ) << GetBuildVersion(); - fprintf( m_file, "; DRILL file {%s} date %s\n", TO_UTF8( msg ), TO_UTF8( DateAndTime() ) ); + fprintf( m_file, "; DRILL file {%s} date %s\n", TO_UTF8( msg ), TO_UTF8( GetISO8601CurrentDateTime() ) ); msg = wxT( "; FORMAT={" ); // Print precision: diff --git a/pcbnew/exporters/place_file_exporter.cpp b/pcbnew/exporters/place_file_exporter.cpp index b8ec4ec20c..0156e82f78 100644 --- a/pcbnew/exporters/place_file_exporter.cpp +++ b/pcbnew/exporters/place_file_exporter.cpp @@ -211,7 +211,7 @@ std::string PLACE_FILE_EXPORTER::GenPositionData() else { // Write file header - snprintf( line, sizeof(line), "### Footprint positions - created on %s ###\n", TO_UTF8( DateAndTime() ) ); + snprintf( line, sizeof(line), "### Footprint positions - created on %s ###\n", TO_UTF8( GetISO8601CurrentDateTime() ) ); buffer += line; @@ -293,7 +293,7 @@ std::string PLACE_FILE_EXPORTER::GenReportData() // Generate header file comments.) char line[1024]; - snprintf( line, sizeof(line), "## Footprint report - date %s\n", TO_UTF8( DateAndTime() ) ); + snprintf( line, sizeof(line), "## Footprint report - date %s\n", TO_UTF8( GetISO8601CurrentDateTime() ) ); buffer += line; wxString Title = GetBuildVersion();