Hi
Get a lot of warning
[Warning] Cannot parse current item's date '1/1/0001 12:00:00 AM'
And nothing is incremented in VS 2011 SP1.
I'm using the latest beta.
Comments: ** Comment from web user: BenXXX **
Hi everybody
I suffered this "Warning mess" also. So I solved it (at least for me) and provide the code/thoughts here.
Conditions:
Windows 7, english
Visual Studio, english (are there other versions? Dunno..)
Local Settings set to another country than englisch/us
This is a common scenario for developers outside the empire. You want english error messages with which you can extract meaningful answers from google. Error messages in suaheli will not help much. But you dont want using these old fashioned elbow and foot measurements. And also use your local datetime.
Simple test in BuildVersionIncrementor.cs
```
Logger.Write(String.Format("Parse DateTime '{0}'", itemDateString), LogLevel.Info);
Logger.Write(String.Format("CultureInfo.InstalledUICulture.Name '{0}'", CultureInfo.InstalledUICulture.Name), LogLevel.Info);
Logger.Write(String.Format("CultureInfo.CurrentCulture.Name '{0}'", CultureInfo.CurrentCulture.Name), LogLevel.Info);
Logger.Write(String.Format("CultureInfo.CurrentUICulture.Name '{0}'", CultureInfo.CurrentUICulture.Name), LogLevel.Info);
Logger.Write(String.Format("CultureInfo.InvariantCulture.Name '{0}'", CultureInfo.InvariantCulture.Name), LogLevel.Info);
```
resulted in
```
[Info] Parse DateTime '22.01.2013 13:36:58'
[Info] CultureInfo.InstalledUICulture.Name 'en-US'
[Info] CultureInfo.CurrentCulture.Name 'en-US'
[Info] CultureInfo.CurrentUICulture.Name 'en-US'
[Info] CultureInfo.InvariantCulture.Name ''
```
==> Always US, but my system has european date format configured!
I don't know why in an VS Addin CurrentCulture delivers en-US. I tested a simple Winforms app. There, CurrentCulture delivers the currently configured format.
So, the workaround is to use Pinvoke:
```
using System.Runtime.InteropServices;
[DllImport("kernel32.dll")]
static extern uint GetUserDefaultLCID();
int lcid = Convert.ToInt32(GetUserDefaultLCID());
CultureInfo formattingCultInfo = new CultureInfo(lcid);
itemFileDate = DateTime.Parse(itemDateString, formattingCultInfo );
```