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

DateTime.ToString() and neutral calendar #171

Closed
FrancoisM opened this issue Feb 2, 2017 · 9 comments
Closed

DateTime.ToString() and neutral calendar #171

FrancoisM opened this issue Feb 2, 2017 · 9 comments

Comments

@FrancoisM
Copy link

That line: should be called with a neutral calendar as for some of my users it throw an exception as per that discussion.

@jamesmontemagno
Copy link
Owner

Are you sure it actually throws an exception? As I pass in an actual value for the format. Which is different then what they are doing in that thread.

@FrancoisM
Copy link
Author

FrancoisM commented Feb 2, 2017

Actual HockeyApp Crash Trace:

 [DateTimeFormatInfo set_Calendar(System.Globalization.Calendar value)]
System.ArgumentOutOfRangeException: Not a valid calendar for the given culture.
Parameter name: value
System.Globalization.DateTimeFormatInfo.set_Calendar(Calendar value)
System.Globalization.DateTimeFormatInfo.DateTimeFormatInfo(CultureData cultureData, Calendar cal)
System.Globalization.CultureInfo.get_DateTimeFormat()
System.Globalization.CultureInfo.GetFormat(Type formatType)
System.Globalization.DateTimeFormatInfo.get_CurrentInfo()
System.DateTime.ToString(string format)
Plugin.Media.MediaPickerDelegate.GetOutputPath(string type, string path, string name)
Plugin.Media.MediaPickerDelegate.<GetPictureMediaFile>d__24.MoveNext()
Plugin.Media.MediaPickerDelegate.<FinishedPickingMedia>d__9.MoveNext()
Social.iOS.Application.Main(string[] args)

@jamesmontemagno
Copy link
Owner

I'll integrate this in, however it should be in bugzilla as it is clearly a mono bug

@FrancoisM
Copy link
Author

I don't know which calendar caused the issue. I don't know how to report crashes with userid on HockeyApp (but that's another issue) in order to find out.
I'll compile my iOS project with Properties>iOSBuild>Advanced>Internalization>all boxes checked and hopefully the issue will disapear (I read some calendars where not linked otherwise).
But you could make your ToString() using invariant culture as it doesn't matter in the case where you call it.

@jamesmontemagno
Copy link
Owner

Cool, thanks for info.

Will do this:

            var now = DateTime.Now;
            string timestamp = $"{now.Year}{now.Month}{now.Day}_{now.Hour}{now.Minute}{now.Second}";

@FrancoisM
Copy link
Author

You already done it! Great!
But why not just ?

DateTime.Now.ToString("yyyMMdd_HHmmss", CultureInfo.InvariantCulture)

@jamesmontemagno
Copy link
Owner

Maybe... do we know for sure it would work?

jamesmontemagno added a commit that referenced this issue Feb 2, 2017
@FrancoisM
Copy link
Author

For sure? No. It should though. UnitTest?

@jamesmontemagno
Copy link
Owner

teheh
well pushing it out

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

2 participants