1
Vote

FormatException: String was not recognized as a valid DateTime

description

I'm trying to run CCStatisticsRC3 (1.3.2822.22029) across our log files. A lot of our logs throw this exception:
 
System.FormatException: String was not recognized as a valid DateTime.
at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
at System.DateTime.Parse(String s)
at CCStatisticsApi.IntegrationResultHelper.SetIntegrationResult(IIntegrationResult integrationResult, XPathNavigator logXml)
at CCStatisticsApi.IntegrationResultHelper.Result(String logFileName, XPathNavigator logXml, String workingDirectory, String artifactDirectory)
at CCStatisticsApi.CCStatisticsPublisher.ProcesLogFile(String logFileName, ICCStatsProject statsProject)
at CCStatisticsApi.ProjectStatisticsPresenter.ProcessLogFile(ICCStatisticsPublisher ccStatisticsPublisherOverride, String logFileName)
at CCStatisticsApi.ProjectStatisticsPresenter.RecalculateStatistics()
at ThoughtWorks.CruiseControl.CCStatistics.MainForm.StartMainBackgroundThreadLoop() in C:\Projects\PM\CCStatistics\CCStatistics\MainForm.cs:line 588
at ThoughtWorks.CruiseControl.CCStatistics.MainForm._OnRecalculateStatisticsButtonClick(Object sender, EventArgs e) in C:\Projects\PM\CCStatistics\CCStatistics\MainForm.cs:line 555
at System.Windows.Forms.Control.OnClick(EventArgs e)
....
 
Unfortunately, this causes the processing run to stop altogether, and the application to exit.
 
Firstly, could the error message please show what the unparsable date string was?
 
Secondly, the application should not exit on unhandled exceptions.
 
Depending upon what this date value is for, it might be possible to continue without placing the value in the results.
 
I suspect this is a number style issue and will post more information if I'm able to find time to investigate further.
 
Thanks.

comments

drewnoakes wrote Apr 25, 2008 at 12:44 PM

This appears due to a mistmatch between ddMM and MMdd ordering. Logs where dd is between 01 and 12 work ok.

Note that this bug is also present in CCStatistics 1.2.

The offending line of code is:

XPathNavigator buildNode = logXml.SelectSingleNode(@"//cruisecontrol/build"); integrationResult.StartTime = DateTime.Parse(buildNode.GetAttribute("date", ""));

It seems that someone changed the region settings on our build server as we used to have dates like "7/13/2007 8:43:44 AM" but now we have dates like "25/04/2008 10:38:54". I don't know how we can get around this in a reliable fashion. It's a shame CruiseControl.NET doesn't use a more global date format such as yyyyMMdd-hh:mm:ss.ffff.

Still, a more helpful error message would be nice :)

wrote Feb 13, 2013 at 5:18 PM