Skip to content

Commit ff84d02

Browse files
author
Sami Kuhmonen
committed
Use invariant culture for post serialization
1 parent d901785 commit ff84d02

File tree

1 file changed

+6
-5
lines changed
  • BlogEngine/BlogEngine.Core/Data/Services

1 file changed

+6
-5
lines changed

BlogEngine/BlogEngine.Core/Data/Services/Json.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using BlogEngine.Core.Data.Models;
22
using System;
33
using System.Collections.Generic;
4+
using System.Globalization;
45
using System.Linq;
56

67
namespace BlogEngine.Core.Data.Services
@@ -24,7 +25,7 @@ public static PostItem GetPost(Post post)
2425
Title = post.Title,
2526
Slug = post.Slug,
2627
RelativeLink = post.RelativeLink,
27-
DateCreated = post.DateCreated.ToString("yyyy-MM-dd HH:mm"),
28+
DateCreated = post.DateCreated.ToString("yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture),
2829
Categories = GetCategories(post.Categories),
2930
Tags = GetTags(post.Tags),
3031
Comments = GetComments(post),
@@ -47,7 +48,7 @@ public static PostDetail GetPostDetail(Post post)
4748
Description = post.Description,
4849
RelativeLink = post.RelativeLink,
4950
Content = post.Content,
50-
DateCreated = post.DateCreated.ToString("yyyy-MM-dd HH:mm"),
51+
DateCreated = post.DateCreated.ToString("yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture),
5152
Categories = GetCategories(post.Categories),
5253
Tags = GetTags(post.Tags),
5354
Comments = GetComments(post),
@@ -81,7 +82,7 @@ public static PageItem GetPage(Page page)
8182
Slug = page.Slug,
8283
Parent = parentOption,
8384
Keywords = page.Keywords,
84-
DateCreated = page.DateCreated.ToString("yyyy-MM-dd HH:mm"),
85+
DateCreated = page.DateCreated.ToString("yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture),
8586
HasChildren = page.HasChildPages,
8687
IsPublished = page.IsPublished,
8788
IsFrontPage = page.IsFrontPage,
@@ -114,7 +115,7 @@ public static PageDetail GetPageDetail(Page page)
114115
Parent = parentOption,
115116
Description = page.Description,
116117
Keywords = page.Keywords,
117-
DateCreated = page.DateCreated.ToString("yyyy-MM-dd HH:mm"),
118+
DateCreated = page.DateCreated.ToString("yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture),
118119
HasChildren = page.HasChildPages,
119120
IsPublished = page.IsPublished,
120121
IsFrontPage = page.IsFrontPage,
@@ -138,7 +139,7 @@ public static CommentItem GetComment(Comment c, List<Comment> postComments)
138139
jc.Email = c.Email == "trackback" ? "pingback" : c.Email;
139140
jc.Author = c.Author;
140141
jc.Title = c.Teaser.Length < 80 ? c.Teaser : c.Teaser.Substring(0, 80) + "...";
141-
jc.DateCreated = c.DateCreated.ToString("yyyy-MM-dd HH:mm");
142+
jc.DateCreated = c.DateCreated.ToString("yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture);
142143
jc.RelativeLink = c.RelativeLink;
143144
jc.HasChildren = postComments.Where(pc => pc.ParentId == c.Id).FirstOrDefault() != null;
144145
jc.Avatar = Gravatar(c);

0 commit comments

Comments
 (0)