Make exported date time strings use ISO8601 format
Also rename the function to be explicit on its result format Fixes https://gitlab.com/kicad/code/kicad/-/issues/15185
This commit is contained in:
parent
c3222b0652
commit
3233bbe0ba
|
@ -32,6 +32,7 @@
|
|||
#include <macros.h>
|
||||
#include <richio.h> // StrPrintf
|
||||
#include <string_utils.h>
|
||||
#include <fmt/chrono.h>
|
||||
|
||||
|
||||
/**
|
||||
|
@ -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() );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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<KIID, EDA_ITEM*> itemMap;
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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" );
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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() ) );
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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() );
|
||||
|
|
|
@ -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() )
|
||||
{
|
||||
|
|
|
@ -369,7 +369,7 @@ bool GENDRILL_WRITER_BASE::GenDrillReportFile( const wxString& aFullFileName )
|
|||
std::vector<DRILL_LAYER_PAIR> 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" );
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue