Skip to content

Commit

Permalink
Use constants where available
Browse files Browse the repository at this point in the history
  • Loading branch information
drewnoakes committed Feb 12, 2024
1 parent f0fbcee commit 83e6bb3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion MetadataExtractor/Util/DateUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ public static bool IsValidTime(int hours, int minutes, int seconds)
minutes is >= 0 and < 60
&& seconds is >= 0 and < 60;

#if NET8_0 || NETSTANDARD2_1
private static readonly DateTime _unixEpoch = DateTime.UnixEpoch;
#else
private static readonly DateTime _unixEpoch = new(1970, 1, 1, 0, 0, 0);
#endif

public static DateTime FromUnixTime(long unixTime) => _unixEpoch.AddSeconds(unixTime);
public static DateTime FromUnixTime(long unixTimeSeconds) => _unixEpoch.AddSeconds(unixTimeSeconds);
}
}

0 comments on commit 83e6bb3

Please sign in to comment.