-
-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ticket #704 : In the website, convert datetime UTC to local datetime
- Loading branch information
Showing
27 changed files
with
144 additions
and
75 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
src/IdServer/SimpleIdServer.IdServer.Website/SidJsonSerializer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) SimpleIdServer. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. | ||
|
||
using SimpleIdServer.IdServer.Domains; | ||
using SimpleIdServer.IdServer.DTOs; | ||
using System.Text.Json; | ||
|
||
namespace SimpleIdServer.IdServer.Website; | ||
|
||
public class SidJsonSerializer | ||
{ | ||
public static T Deserialize<T>(string json) where T : class | ||
{ | ||
var serializeOptions = new JsonSerializerOptions | ||
{ | ||
Converters = | ||
{ | ||
new UtcDateTimeConverter() | ||
} | ||
}; | ||
var searchResult = JsonSerializer.Deserialize<T>(json, serializeOptions); | ||
return searchResult; | ||
} | ||
|
||
public static SearchResult<Client> DeserializeSearchClients(string json) | ||
{ | ||
var result = Deserialize<SearchResult<Client>>(json); | ||
foreach(var client in result.Content) | ||
{ | ||
client.CreateDateTime = client.CreateDateTime.ToLocalTime(); | ||
client.UpdateDateTime = client.UpdateDateTime.ToLocalTime(); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
public static IEnumerable<Client> DeserializeClients(string json) | ||
{ | ||
var result = Deserialize<IEnumerable<Client>>(json); | ||
foreach (var client in result) | ||
{ | ||
client.CreateDateTime = client.CreateDateTime.ToLocalTime(); | ||
client.UpdateDateTime = client.UpdateDateTime.ToLocalTime(); | ||
} | ||
|
||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.