More cleanup

pull/826/head
Oleksii Holub 3 years ago
parent 91ea7a443c
commit 338566c1d6

@ -1,5 +1,4 @@
using System; using System.IO;
using System.IO;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using DiscordChatExporter.Core.Discord; using DiscordChatExporter.Core.Discord;
@ -60,8 +59,8 @@ public partial record ExportRequest
"%C" => channel.Name, "%C" => channel.Name,
"%p" => channel.Position?.ToString() ?? "0", "%p" => channel.Position?.ToString() ?? "0",
"%P" => channel.Category.Position?.ToString() ?? "0", "%P" => channel.Category.Position?.ToString() ?? "0",
"%a" => (after ?? Snowflake.Zero).ToDate().ToString("yyyy-MM-dd"), "%a" => after?.ToDate().ToString("yyyy-MM-dd") ?? "",
"%b" => (before?.ToDate() ?? DateTime.Now).ToString("yyyy-MM-dd"), "%b" => before?.ToDate().ToString("yyyy-MM-dd") ?? "",
"%%" => "%", "%%" => "%",
_ => m.Value _ => m.Value
}) })
@ -93,7 +92,7 @@ public partial record ExportRequest
// Date range // Date range
if (after is not null || before is not null) if (after is not null || before is not null)
{ {
buffer.Append(" ("); buffer.Append(' ').Append('(');
// Both 'after' and 'before' are set // Both 'after' and 'before' are set
if (after is not null && before is not null) if (after is not null && before is not null)
@ -111,11 +110,11 @@ public partial record ExportRequest
buffer.Append($"before {before.Value.ToDate():yyyy-MM-dd}"); buffer.Append($"before {before.Value.ToDate():yyyy-MM-dd}");
} }
buffer.Append(")"); buffer.Append(')');
} }
// File extension // File extension
buffer.Append($".{format.GetFileExtension()}"); buffer.Append('.').Append(format.GetFileExtension());
return PathEx.EscapeFileName(buffer.ToString()); return PathEx.EscapeFileName(buffer.ToString());
} }

Loading…
Cancel
Save