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

ToString() formatting #8

Closed
MarijnPessers opened this issue May 3, 2020 · 1 comment
Closed

ToString() formatting #8

MarijnPessers opened this issue May 3, 2020 · 1 comment

Comments

@MarijnPessers
Copy link

I am using the ToString() method to get the date in a string to be useable by an API.
I would like to be able to pass a culture to the ToString() method so we can control the way the result looks like.

@Giannoudis
Copy link
Owner

You can use the TimeFormatter.GetDateTime() to format a date.

public void ToStringCultureTest()
{
    var start = new DateTime(2013, 12, 15);
    var culture = new CultureInfo("en-US");
    var enUsFormatter = new TimeFormatter(culture);
    Assert.Equal(start.ToString(culture), enUsFormatter.GetDateTime(start) );
} // ToStringCultureTest

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