Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error by desiralize DateTime on german system #35

Closed
gitgordon opened this issue Jul 20, 2015 · 3 comments
Closed

Error by desiralize DateTime on german system #35

gitgordon opened this issue Jul 20, 2015 · 3 comments

Comments

@gitgordon
Copy link

Hello,
by deserialize a DateTime object on a german windows the new DateTime is wrong (see example).

DateTime date = new DateTime(2015, 7, 20);
YAXLib.YAXSerializer s = new YAXLib.YAXSerializer(typeof(DateTime));
string xml = s.Serialize(date);
Console.WriteLine(xml); // <DateTime>07/20/2015 00:00:00</DateTime>
object obj = s.Deserialize(xml);
Console.WriteLine(obj); // 01.01.0001 00:00:00

This is because the ParseDateTimeTimeZoneSafe method in the StringUtils.cs class does not use the IFormatProvider parameter. Instead of using:

if (!DateTimeOffset.TryParse(str, out dto))

you must use:

if (!DateTimeOffset.TryParse(str, formatProvider, System.Globalization.DateTimeStyles.None, out dto))

Thank you for fixing this issue.
Gordon

@diegobarbosa
Copy link

Is this fixed?

@304NotModified
Copy link
Collaborator

I think not, but you could send a PR for it?

@axunonb
Copy link
Collaborator

axunonb commented Feb 28, 2021

Fixed with #58

@axunonb axunonb closed this as completed Feb 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants