From a3b54b13262fbd1ddd896fd137c0d69c97037765 Mon Sep 17 00:00:00 2001 From: Florian Stinglmayr Date: Fri, 9 Dec 2022 17:51:46 +0100 Subject: [PATCH] add DateTime property variant for CompletedAt --- EDPlayerJournal/BGS/InfluenceSupport.cs | 6 +++--- EDPlayerJournal/BGS/MissionCompleted.cs | 6 +++--- EDPlayerJournal/BGS/ThargoidKill.cs | 5 ----- EDPlayerJournal/BGS/Transaction.cs | 17 ++++++++++++++--- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/EDPlayerJournal/BGS/InfluenceSupport.cs b/EDPlayerJournal/BGS/InfluenceSupport.cs index af88659..90c3bd8 100644 --- a/EDPlayerJournal/BGS/InfluenceSupport.cs +++ b/EDPlayerJournal/BGS/InfluenceSupport.cs @@ -21,12 +21,12 @@ public class InfluenceSupport : Transaction { /// public MissionAcceptedEntry? AcceptedEntry { get; set; } - public override string CompletedAt { + public override DateTime? CompletedAtDateTime { get { if (RelevantMission == null) { - return ""; + return null; } - return RelevantMission.Timestamp.ToString("dd.MM.yyyy hh:mm UTC"); + return RelevantMission.Timestamp; } } diff --git a/EDPlayerJournal/BGS/MissionCompleted.cs b/EDPlayerJournal/BGS/MissionCompleted.cs index 84f18e6..67ab66f 100644 --- a/EDPlayerJournal/BGS/MissionCompleted.cs +++ b/EDPlayerJournal/BGS/MissionCompleted.cs @@ -11,12 +11,12 @@ public class MissionCompleted : Transaction { public MissionCompleted() { } - public override string CompletedAt { + public override DateTime? CompletedAtDateTime { get { if (CompletedEntry == null) { - return ""; + return null; } - return CompletedEntry.Timestamp.ToString("dd.MM.yyyy HH:mm UTC"); + return CompletedEntry.Timestamp; } } diff --git a/EDPlayerJournal/BGS/ThargoidKill.cs b/EDPlayerJournal/BGS/ThargoidKill.cs index 5b365a2..f8baada 100644 --- a/EDPlayerJournal/BGS/ThargoidKill.cs +++ b/EDPlayerJournal/BGS/ThargoidKill.cs @@ -1,9 +1,4 @@ using EDPlayerJournal.Entries; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace EDPlayerJournal.BGS; diff --git a/EDPlayerJournal/BGS/Transaction.cs b/EDPlayerJournal/BGS/Transaction.cs index 6048ff5..5ca711c 100644 --- a/EDPlayerJournal/BGS/Transaction.cs +++ b/EDPlayerJournal/BGS/Transaction.cs @@ -6,18 +6,29 @@ namespace EDPlayerJournal.BGS; public class Transaction : IComparable { public List Entries { get; } = new List(); - public virtual string CompletedAt { + public string CompletedAt { + get { + DateTime? datetime = CompletedAtDateTime; + if (datetime == null) { + return "Unknown"; + } + + return datetime.Value.ToString("dd.MM.yyyy HH:mm UTC"); + } + } + + public virtual DateTime? CompletedAtDateTime { get { var items = Entries .OrderBy(x => x.Timestamp) .ToArray() ; if (items == null || items.Length == 0) { - return "Unknown"; + return null; } Entry last = items.Last(); - return last.Timestamp.ToString("dd.MM.yyyy HH:mm UTC"); + return last.Timestamp; } }