Skip to content

Commit

Permalink
Make UploadReplay fill in the date
Browse files Browse the repository at this point in the history
  • Loading branch information
Simyon264 committed Oct 22, 2024
1 parent 28cb25d commit edee4ae
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion ReplayBrowser/Controllers/ReplayController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Authorization;
using System.Globalization;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
Expand Down Expand Up @@ -244,6 +245,22 @@ IFormCollection form
try
{
replay = _replayParserService.FinalizeReplayParse(reader, null);
var replayFileName = Path.GetFileName(replay.Link);
var storageUrl = _replayParserService.GetStorageUrlFromReplayLink(replay.Link);
var match = storageUrl.ReplayRegexCompiled.Match(replayFileName);
if (match.Success)
{
try
{
var date = DateTime.ParseExact(match.Groups[1].Value, "yyyy_MM_dd-HH_mm", CultureInfo.InvariantCulture);
replay.Date = date.ToUniversalTime();
}
catch (FormatException)
{
var date = DateTime.ParseExact(match.Groups[1].Value, "yyyy-MM-dd", CultureInfo.InvariantCulture);
replay.Date = date.ToUniversalTime();
}
}
}
catch (Exception e)
{
Expand Down

0 comments on commit edee4ae

Please sign in to comment.