Explain me this code

void ATimeOfDayHandler::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
ElapsedSeconds += (DeltaTime * TimeScale);
if(ElapsedSeconds > 60)
{
ElapsedSeconds -= 60;
Minutes++;
if (Minutes > 60)
{
Minutes -= 60;
Hours++;
}
OnTimeChanged.Broadcast(Hours, Minutes);
}
}
In above code what the lines below do:

 ElapsedSeconds += (DeltaTime * TimeScale);

and

`ElapsedSeconds -= 60;`

Tick runs on every frame, which is not consistent as not consistent can be frame-per-seconds and tick is what powers entire engine, it makes things move on the screen on per frame basis. So if tick runs on each frame, how you can make things move according to time not frames? that what DeltaTime is for. DeltaTime is estimated time passed between frames, if you add it up in each tick you will count up the time passed, if you multiply DeltaTime with other delta values (like speed) that delta’s unit turn in to unit/second (in case of speed it will be distance/second). Multiplying DeltaTime like in this case effectively controls speed of time, since if you multiply delta by 2 twice of time will pass between the frames.

the 2nd thing simply subtracts 60 seconds when minute is passed.

That said whatever that code is it’s reinventing the wheel there FTimeSpan to count up that deals with seacounds minutes and hours:

You can scale deltatime with time dilation (there also global time dilation in the engine)

There also timers to count time, normally you use those,.

…but counting time in tick gives more freedom in controlling flow of time, i suspect author of the code wanted to scale time flow on single actor on a specific variable which timers and time dilation don’t let you do it. Still he could just use FTimespan to deal with time units