EdiWang / Moonglade

The ASP.NET Core blog system of https://edi.wang, runs on Microsoft Azure
https://edi.wang
GNU General Public License v3.0
514 stars 136 forks source link

Incorrect RouteLink on de-DE systems #822

Closed EdiWang closed 1 month ago

EdiWang commented 1 month ago

Describe the bug

RouteLink is wrong on systems with German language setup.

To Reproduce Steps to reproduce the behavior:

  1. Go to admin and publish a new blog post
  2. View the blog post
  3. See 404 error

Expected behavior Blog post should be displayed

Additional context

Root cause:

post.RouteLink = $"{post.PubDateUtc.GetValueOrDefault():yyyy/M/d}/{postEditModel.Slug}";

Is not culture aware.

EdiWang commented 1 month ago

Thanks @saigkill for finding this bug.

EdiWang commented 1 month ago

To reproduce

var cultureInfo = new CultureInfo("de-DE");

Thread.CurrentThread.CurrentCulture = cultureInfo;
Thread.CurrentThread.CurrentUICulture = cultureInfo;

var str = $"{DateTime.UtcNow:yyyy/M/d}";

// str: 2024.9.21