Display formatted timestamps in reports

This commit is contained in:
ConfusedPolarBear 2022-09-25 17:13:59 -05:00
parent c3c986152d
commit e18adc84f1
3 changed files with 9 additions and 2 deletions

View File

@ -228,11 +228,11 @@
<p>{{ $episode.Title }}</p> <p>{{ $episode.Title }}</p>
<p> <p>
Old: {{ $old.IntroStart }} - {{ $old.IntroEnd }} Old: {{ $old.FormattedStart }} - {{ $old.FormattedEnd }}
(<span class="duration old">{{ $old.Duration }}</span>) (<span class="duration old">{{ $old.Duration }}</span>)
(valid: {{ $old.Valid }}) <br /> (valid: {{ $old.Valid }}) <br />
New: {{ $new.IntroStart }} - {{ $new.IntroEnd }} New: {{ $new.FormattedStart }} - {{ $new.FormattedEnd }}
(<span class="duration new">{{ $new.Duration }}</span>) (<span class="duration new">{{ $new.Duration }}</span>)
(valid: {{ $new.Valid }}) <br /> (valid: {{ $new.Valid }}) <br />

View File

@ -107,6 +107,10 @@ func unmarshalReport(path string) structs.Report {
// Round the duration to the nearest second to avoid showing 8 decimal places in the report // Round the duration to the nearest second to avoid showing 8 decimal places in the report
intro.Duration = float32(math.Round(float64(intro.Duration))) intro.Duration = float32(math.Round(float64(intro.Duration)))
// Pretty print the intro start and end times
intro.FormattedStart = (time.Duration(intro.IntroStart) * time.Second).String()
intro.FormattedEnd = (time.Duration(intro.IntroEnd) * time.Second).String()
show, season := intro.Series, intro.Season show, season := intro.Series, intro.Season
// If this show hasn't been seen before, allocate space for it // If this show hasn't been seen before, allocate space for it

View File

@ -12,6 +12,9 @@ type Intro struct {
Duration float32 Duration float32
Valid bool Valid bool
FormattedStart string
FormattedEnd string
ShowSkipPromptAt float32 ShowSkipPromptAt float32
HideSkipPromptAt float32 HideSkipPromptAt float32
} }