rj-action-library/Runtime/Time/DateTime/DateMath.cs

33 lines
691 B
C#
Raw Normal View History

2025-06-19 17:22:25 +00:00
using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
using System;
using Godot;
namespace Rokojori
{
public static class DateMath
{
2025-06-23 11:16:01 +00:00
2025-07-11 08:16:45 +00:00
public static bool IsNewerThan( this DateTimeOffset a, DateTimeOffset b )
{
var difference = GetDifference( a, b );
return difference > 0;
}
public static float GetDifference( this DateTimeOffset a, DateTimeOffset b )
2025-06-19 17:22:25 +00:00
{
return (float) ( ( a - b ).TotalSeconds );
}
2025-07-11 08:16:45 +00:00
public static bool HasExpired( this DateTimeOffset oldTime, float duration )
2025-06-19 17:22:25 +00:00
{
2025-07-11 08:16:45 +00:00
var difference = GetDifference( DateTimeOffset.Now, oldTime );
2025-06-19 17:22:25 +00:00
return difference >= duration;
}
}
}