diff options
author | Manish Sinha <manishsinha.tech@gmail.com> | 2010-09-18 17:12:53 +0530 |
---|---|---|
committer | Manish Sinha <manishsinha.tech@gmail.com> | 2010-09-18 17:12:53 +0530 |
commit | 63e3a4ce616c01b49b4f1e6ddf2a4e7b54c58bac (patch) | |
tree | d93f21b20c7953ffe7e628b97fc4cfe504bf0172 /Zeitgeist | |
parent | c9c81a5dd234194b68c2ee29255b68605c46fac4 (diff) |
Added DateTime support in Zeitgeist.Datamodel.Event for the Property Timestamp
Diffstat (limited to 'Zeitgeist')
-rw-r--r-- | Zeitgeist/Datamodel/Event.cs | 16 | ||||
-rw-r--r-- | Zeitgeist/Datamodel/Interpretation.cs | 12 |
2 files changed, 25 insertions, 3 deletions
diff --git a/Zeitgeist/Datamodel/Event.cs b/Zeitgeist/Datamodel/Event.cs index 6ea4975..588712f 100644 --- a/Zeitgeist/Datamodel/Event.cs +++ b/Zeitgeist/Datamodel/Event.cs @@ -26,7 +26,7 @@ namespace Zeitgeist.Datamodel /// Event timestamp defined as milliseconds since the Epoch. /// By default it is set to the moment of instance creation /// </summary> - public UInt64 Timestamp + public DateTime Timestamp { get;set; } @@ -102,7 +102,7 @@ namespace Zeitgeist.Datamodel ulong timestamp; UInt64.TryParse(raw.metadata[(int)EventMetadataPosition.Timestamp], out timestamp); - e.Timestamp = timestamp; + e.Timestamp = Epoch.AddMilliseconds(timestamp); e.Actor = raw.metadata[(int)EventMetadataPosition.Actor]; @@ -157,6 +157,14 @@ namespace Zeitgeist.Datamodel { return RawEvent.FromEvent(this); } + + /// <summary> + /// The DateTime of UNIX Epoch + /// </summary> + /// <remarks> + /// UNIX Epoch is January 01, 1970 00:00:00 UTC + /// </remarks> + public static DateTime Epoch = new DateTime(1970, 1,1, 0,0,0, DateTimeKind.Utc); } /// <summary> @@ -252,7 +260,9 @@ namespace Zeitgeist.Datamodel metaDataList.Add(null); metaDataList[(int)EventMetadataPosition.Id] = ev.Id.ToString(); - metaDataList[(int)EventMetadataPosition.Timestamp] = ev.Timestamp.ToString(); + + TimeSpan now = ev.Timestamp - Event.Epoch; + metaDataList[(int)EventMetadataPosition.Timestamp] = ((int)(now.Ticks / 10000)).ToString(); metaDataList[(int)EventMetadataPosition.Actor] = ev.Actor; metaDataList[(int)EventMetadataPosition.Interpretation] = ev.Interpretation.Value; metaDataList[(int)EventMetadataPosition.Manifestation] = ev.Manifestation.Value; diff --git a/Zeitgeist/Datamodel/Interpretation.cs b/Zeitgeist/Datamodel/Interpretation.cs index fb8a290..749d327 100644 --- a/Zeitgeist/Datamodel/Interpretation.cs +++ b/Zeitgeist/Datamodel/Interpretation.cs @@ -14,6 +14,9 @@ namespace Zeitgeist.Datamodel /// </remarks> public class Interpretation { + /// <summary> + /// The singleton Instance of Interpretation + /// </summary> public static Interpretation Instance { get @@ -333,6 +336,15 @@ namespace Zeitgeist.Datamodel } } + /// <summary> + /// Search for an interpretation KeyValuePair provided the interpretation string + /// </summary> + /// <param name="interpretation"> + /// The Interpretation of type <see cref="System.String"/> + /// </param> + /// <returns> + /// The parsed value of Interpretation <see cref="KeyValuePair<System.String, System.String>"/> + /// </returns> public KeyValuePair<string, string> Search(string interpretation) { if(string.Equals(_alarm.Value, interpretation)) |