Skip to content

Commit 2a11016

Browse files
Merge pull request #432 from craigmoliver/master
Coordinated Universal Time support
2 parents 8d37347 + 1369527 commit 2a11016

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/shared/Z.EF.Plus.Audit.Shared/AuditConfiguration.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public AuditConfiguration()
4242
IsAuditedDictionary = new ConcurrentDictionary<string, bool>();
4343
ValueFormatterDictionary = new ConcurrentDictionary<string, Func<object, object>>();
4444

45-
45+
UseCoordinatedUniversalTime = false;
4646
#if EF5 || EF6
4747
UseNullForDBNullValue = true;
4848
#endif
@@ -129,6 +129,10 @@ public AuditConfiguration()
129129
/// <value>True if exclude relationship if one excluded, false if not.</value>
130130
public bool ExcludeRelationshipIfOneExcluded { get; set; }
131131

132+
/// <summary>Gets or sets a value determining if Coordinated Universal Time (UTC) should be used instead of local time.</summary>
133+
/// <value>true if UTC, false if local</value>
134+
public bool UseCoordinatedUniversalTime { get; set; }
135+
132136
#if EF5 || EF6
133137
/// <summary>
134138
/// Gets or sets a value indicating whether null value should be used in the Audit instead of DBNull.Value
@@ -163,6 +167,7 @@ public AuditConfiguration Clone()
163167
SoftAddedPredicates = new List<Func<object, bool>>(SoftAddedPredicates),
164168
SoftDeletedPredicates = new List<Func<object, bool>>(SoftDeletedPredicates),
165169
ExcludeRelationshipIfOneExcluded = ExcludeRelationshipIfOneExcluded,
170+
UseCoordinatedUniversalTime = UseCoordinatedUniversalTime,
166171
#if EF5 || EF6
167172
UseNullForDBNullValue = UseNullForDBNullValue
168173
#endif

src/shared/Z.EF.Plus.Audit.Shared/AuditEntry.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void Build(Audit parent, EntityEntry entry)
3838

3939
if (CreatedDate == DateTime.MinValue)
4040
{
41-
CreatedDate = DateTime.Now;
41+
CreatedDate = (parent.Configuration.UseCoordinatedUniversalTime) ? DateTime.UtcNow : DateTime.Now;
4242
}
4343

4444
if (Entry == null)

0 commit comments

Comments
 (0)