Update Subtasks In Markdown Files

Better ISO support

Only reviewing Files when comparing

Extracted sections from UpdateSubTasksInMarkdownFiles
This commit is contained in:
2024-12-26 14:14:31 -07:00
parent 2361796bbf
commit fb9289a572
13 changed files with 1208 additions and 395 deletions

View File

@ -1,12 +1,15 @@
using System.Globalization;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace File_Folder_Helper.Models;
internal record NginxFileSystem(string Name,
string Type,
string MTime,
float Size)
internal record NginxFileSystem([property: JsonPropertyName("name")] string Name,
DateTime? LastModified,
[property: JsonPropertyName("mtime")] string MTime,
Uri? URI,
[property: JsonPropertyName("type")] string Type,
[property: JsonPropertyName("size")] float? Length)
{
public override string ToString()
@ -15,6 +18,25 @@ internal record NginxFileSystem(string Name,
return result;
}
public static NginxFileSystem Get(string format, TimeZoneInfo timeZoneInfo, string name, string mTime, Uri uri, string type, float? size)
{
NginxFileSystem result;
DateTime dateTime;
DateTime? nullableDateTime;
if (mTime.Length != format.Length + 4 || !DateTime.TryParseExact(mTime[..format.Length], format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime))
nullableDateTime = null;
else
nullableDateTime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(dateTime, mTime[(format.Length + 1)..], timeZoneInfo.Id);
result = new(name, nullableDateTime, mTime, uri, type, size);
return result;
}
public static string GetFormat() =>
"ddd, dd MMM yyyy HH:mm:ss";
public static NginxFileSystem Get(string format, TimeZoneInfo timeZoneInfo, Uri uri, NginxFileSystem nginxFileSystem) =>
Get(format, timeZoneInfo, nginxFileSystem.Name, nginxFileSystem.MTime, uri, nginxFileSystem.Type, nginxFileSystem.Length);
}
[JsonSourceGenerationOptions(WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]