Skip to content

Commit d05eb10

Browse files
JacobWang-bcFosol
authored andcommitted
save utc in the DB , display local time in the content headline (bcgov#2548)
1 parent 3d00ce2 commit d05eb10

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

services/net/auto-clipper/AutoClipperManager.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -582,9 +582,11 @@ private ContentModel BuildClipContentModel(ContentModel sourceContent, ClipDefin
582582
var autoTags = _tags?.Where(t => this.Options.ApplyTags.Contains(t.Code));
583583
var tags = autoTags != null ? sourceContent.Tags.AppendRange(autoTags.Select(at => new ContentTagModel(at.Id, at.Code, at.Name))) : sourceContent.Tags;
584584

585-
// Calculate clip time = parent content publish time + clip start offset
586-
var clipTime = sourceContent.PublishedOn?.Add(definition.Start);
587-
var timePrefix = clipTime?.ToString("HH:mm");
585+
// Calculate clip time = parent content publish time + clip start offset (UTC for storage)
586+
var clipTimeUtc = sourceContent.PublishedOn?.Add(definition.Start);
587+
// For display in headline, convert to local timezone
588+
var clipTimeLocal = clipTimeUtc?.ToTimeZone(this.Options.TimeZone);
589+
var timePrefix = clipTimeLocal?.ToString("HH:mm");
588590
var clipTitle = FormatClipTitle(definition.Title);
589591
var categoryLabel = FormatClipCategory(definition.Category);
590592
var headlineCore = string.IsNullOrEmpty(timePrefix) ? clipTitle : $"{timePrefix} - {clipTitle}";
@@ -610,7 +612,7 @@ private ContentModel BuildClipContentModel(ContentModel sourceContent, ClipDefin
610612
Summary = $"[AutoClipper:{definition.Category}]\n{clipSummary}",
611613
Body = transcriptBody,
612614
SourceUrl = sourceContent.SourceUrl,
613-
PublishedOn = clipTime ?? sourceContent.PublishedOn,
615+
PublishedOn = clipTimeUtc ?? sourceContent.PublishedOn,
614616
PostedOn = DateTime.UtcNow,
615617
Tags = tags,
616618
Topics = sourceContent.Topics,

0 commit comments

Comments
 (0)