diff options
| author | Paweł Bernaciak <pawelbernaciak@zohomail.eu> | 2023-02-10 21:24:11 +0100 |
|---|---|---|
| committer | Paweł Bernaciak <pawelbernaciak@zohomail.eu> | 2023-02-10 21:24:11 +0100 |
| commit | 7fefe217c8462444ecb9806599e70afe2a7102ea (patch) | |
| tree | 49cd108ab96a756fe67ac58f980d1385c17e09df /CoreWiki/Models | |
| parent | 00c3b32e2db200a2f42396ac7f8381704ec97268 (diff) | |
Time display fixes
Diffstat (limited to 'CoreWiki/Models')
| -rw-r--r-- | CoreWiki/Models/Article.cs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/CoreWiki/Models/Article.cs b/CoreWiki/Models/Article.cs index c461758..53c2706 100644 --- a/CoreWiki/Models/Article.cs +++ b/CoreWiki/Models/Article.cs @@ -1,4 +1,7 @@ +using NodaTime; +using NodaTime.Extensions; using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; namespace CoreWiki.Models; @@ -6,6 +9,16 @@ public class Article { [Required, Key] public string Topic { get; set; } - public DateTime Published { get; set; } = DateTime.UtcNow; + [NotMapped] + public Instant Published { get; set; } = SystemClock.Instance.GetCurrentInstant(); + [Obsolete("This property is only for serialization")] + [DataType(DataType.DateTime)] + [Column("Published")] + public DateTime PublishedDateTime + { + get => Published.ToDateTimeUtc(); + set => Published = DateTime.SpecifyKind(value, DateTimeKind.Utc).ToInstant(); + } + [DataType(DataType.MultilineText)] public string Content { get; set; } }
\ No newline at end of file |
