GetDateDayWithSuffix

Contents

Namespace

SubSonic.Extensions.Dates


Summary

Given a datetime object, returns the formatted day, "15th"

Example

var output="The post was published on the "+Post.PublishedDate.GetDateDayWithSuffix();

Unit Test

public void GetDateDayWithSuffix_Should_Be_April_16th_For_ParsedDate() {
    var today = DateTime.Parse("4/16/2009");
    var result = today.GetDateDayWithSuffix();
    Assert.Equal("16th", result);
}

Comments

SubSonic 3.0 implements this as an extension on System.DateTime - 2.x uses a static method on SubSonic.Sugar.Dates.