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

Ordinal number suffixes #328

Closed
aaronpowell opened this issue Aug 20, 2014 · 4 comments
Closed

Ordinal number suffixes #328

aaronpowell opened this issue Aug 20, 2014 · 4 comments
Milestone

Comments

@aaronpowell
Copy link

It'd be useful to be able to get just the ordinal suffix, so st, nd, rd, th for numbers, especially when working with dates.

Use case:

Assert.That("20th August 2014", Is.EqualTo(new DateTime(2014, 8, 20).<something>());
@MehdiK
Copy link
Member

MehdiK commented Aug 21, 2014

I like this.

I think this is a perfect fit for Humanize method. Maybe we should ask for this behavior using an optional param (which I don't really like) or create an overload with a format string (in which the formatter would have to be mandatory to differentiate it from the current Humanize method. Alternatively we could create a new method for this. ToOrdinalWords maybe?

@aaronpowell
Copy link
Author

It begs the only question, how would you make that test pass?

@hazzik
Copy link
Member

hazzik commented Aug 22, 2014

Just quick code:

public static string ToOrdinalWords(this DateTime dt) 
{
    return string.Format("{0} {1:MMMM yyyy}", dt.Day.Ordinalize(), dt);
}

UPD: fixed

@clairernovotny
Copy link
Member

Merged in 3d71fd9

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