2

I am using humanizer for getting human friendly string telling how far back or forward in time some date is. Some examples is here:

DateTime.UtcNow.AddHours(-30).Humanize() => "yesterday"
DateTime.UtcNow.AddHours(-2).Humanize() => "2 hours ago"
DateTime.UtcNow.AddHours(30).Humanize() => "tomorrow"
DateTime.UtcNow.AddHours(2).Humanize() => "2 hours from now"
DateTimeOffset.AddHours(1).Humanize() => "an hour from now"

The library provide capability for different culture:

public static string Humanize(this DateTime input, bool utcDate = true, DateTime? dateToCompareAgainst = null, CultureInfo culture = null)

My usage (using Persian culture) is:

myDate.Humanize(culture: new CultureInfo("fa-IR"))

The problem is that it works fine in IIS Express in Visual Studio 2013, But it shows english in IIS in windows 8.

So my result is:

"14 days ago" //In IIS
"14 روز پیش" //In Visual Studio 2013
Filburt
  • 17,626
  • 12
  • 64
  • 115
Seyed Morteza Mousavi
  • 6,855
  • 8
  • 43
  • 69
  • This _IIS Express in Visual Studio 2013_ in a different windows version rather than Win8? Or all of them in the same machine? You mean it is okey in VS but not in IIS? Maybe an IIS settings override your culture information? – Soner Gönül Mar 23 '16 at 07:16
  • @SonerGönül Both IIS is on the same machine. If you need portion of setting I will add to question in an update. – Seyed Morteza Mousavi Mar 23 '16 at 07:21

1 Answers1

0

This question looks quite old now and may already have been solved. In .NET Framework 3.5 and earlier versions, cultural data is provided by both the Windows operating system and the .NET Framework. Perhaps this is the reason for the discrepancy between running via IIS and then running locally thru Visual Studio.

If your project cannot be updated, there is a workaround here to add Persian. https://www.codeproject.com/Articles/32096/How-to-Set-PersianCalendar-to-CultureInfo

Stephen85
  • 250
  • 1
  • 15