mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Store the date a build is created
This commit is contained in:
27
src/Jackett.Common/Utils/BuildDate.cs
Normal file
27
src/Jackett.Common/Utils/BuildDate.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Jackett.Common.Utils
|
||||
{
|
||||
public static class BuildDate
|
||||
{
|
||||
public static DateTime GetBuildDateTime()
|
||||
{
|
||||
Assembly commonAssembly = Assembly.GetExecutingAssembly();
|
||||
var attribute = commonAssembly.GetCustomAttribute<BuildDateAttribute>();
|
||||
return attribute?.DateTime ?? default(DateTime);
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Assembly)]
|
||||
public class BuildDateAttribute : Attribute
|
||||
{
|
||||
public BuildDateAttribute(string value)
|
||||
{
|
||||
DateTime = DateTime.ParseExact(value, "yyyyMMddHHmmss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal);
|
||||
}
|
||||
|
||||
public DateTime DateTime { get; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user