~zeitgeist-sharp/zeitgeist-sharp/packaging

« back to all changes in this revision

Viewing changes to Zeitgeist/Datamodel/Event.cs

  • Committer: Manish Sinha
  • Date: 2010-09-18 11:42:53 UTC
  • Revision ID: manishsinha.tech@gmail.com-20100918114253-cllkz8ed7oi8std4
Added DateTime support in Zeitgeist.Datamodel.Event for the Property Timestamp

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
                /// Event timestamp defined as milliseconds since the Epoch.
27
27
                /// By default it is set to the moment of instance creation
28
28
                /// </summary>
29
 
                public UInt64 Timestamp
 
29
                public DateTime Timestamp
30
30
                {
31
31
                        get;set;
32
32
                }
102
102
                        
103
103
                        ulong timestamp;
104
104
                        UInt64.TryParse(raw.metadata[(int)EventMetadataPosition.Timestamp], out timestamp);
105
 
                        e.Timestamp = timestamp;
 
105
                        e.Timestamp = Epoch.AddMilliseconds(timestamp);
106
106
                        
107
107
                        e.Actor = raw.metadata[(int)EventMetadataPosition.Actor];
108
108
                        
157
157
                {
158
158
                        return RawEvent.FromEvent(this);
159
159
                }
 
160
                
 
161
                /// <summary>
 
162
                /// The DateTime of UNIX Epoch
 
163
                /// </summary>
 
164
                /// <remarks>
 
165
                /// UNIX Epoch is January 01, 1970 00:00:00 UTC
 
166
                /// </remarks>
 
167
                public static DateTime Epoch = new DateTime(1970, 1,1, 0,0,0, DateTimeKind.Utc);
160
168
        }
161
169
        
162
170
        /// <summary>
252
260
                                metaDataList.Add(null);
253
261
                        
254
262
                        metaDataList[(int)EventMetadataPosition.Id] = ev.Id.ToString();
255
 
                        metaDataList[(int)EventMetadataPosition.Timestamp] = ev.Timestamp.ToString();
 
263
                        
 
264
                        TimeSpan now = ev.Timestamp - Event.Epoch;
 
265
                        metaDataList[(int)EventMetadataPosition.Timestamp] = ((int)(now.Ticks / 10000)).ToString();
256
266
                        metaDataList[(int)EventMetadataPosition.Actor] = ev.Actor;
257
267
                        metaDataList[(int)EventMetadataPosition.Interpretation] = ev.Interpretation.Value;
258
268
                        metaDataList[(int)EventMetadataPosition.Manifestation] = ev.Manifestation.Value;