Tyrrrz / DiscordChatExporter

Exports Discord chat logs to a file
MIT License
7.18k stars 655 forks source link

How to configure rfc3339/iso8601 date format in HTML output? #1158

Open Zwelf opened 7 months ago

Zwelf commented 7 months ago

Version

v2.41

Flavor

CLI (Command-Line Interface)

Platform

linux

Export format

HTML

Steps to reproduce

With --date replacing --locale, I don't see any way to configure iso8601 date format for html output. Do I miss how to configure it? Otherwise I'd be really happy if I could set a "international" iso8601 locale.

Details

Checklist

Tyrrrz commented 7 months ago

Yes, --dateformat was removed as part of #879. The main reason for that was that the application used a lot more than just one format, but only one of them was somewhat configurable.

The locale option generally offers more flexibility, as you can achieve the same behavior that the Discord app provides via the Language tab in settings. Unfortunately, that also means setting a non-locale-specific date format (such as ISO8601) is no longer possible.

Note that if you hover over the date, the tooltip will show the date in a locale-specific full date-time format, which is mostly unambiguous (unlike mm/dd/yyyy). Otherwise, if you really need deterministic timestamp formats, it's recommended to use the JSON export instead. The HTML export is intended to mimic the look and behavior of the Discord app.

Zwelf commented 7 months ago

Thanks for your fast reply :). How viable would it be to add some iso-locale and special case it to always use this format?

Digging through #879, it seems like I would need to modify FormatDate, CultureInfo = ... and probably AvailableLocales? Would you accept a pr that adds such a locale, or would you prefer some other command line argument? (Not sure yet if and when I have time to get to creating a pr)

Tyrrrz commented 7 months ago

Would you accept a pr that adds such a locale, or would you prefer some other command line argument?

I don't think I want to include it in the scope of the project, at least as of now. You're welcome to make a fork for your own usage, though.

p5nbTgip0r commented 5 months ago

The en-SE locale provides a similar format to ISO8601: 2024-01-12 21:31, tooltip: Friday, 12 January 2024 21:31

This is the snippet I used to list locales and their date formats: https://dotnetfiddle.net/TWm6Et

using System;
using System.Globalization;

class Program
{
    static void Main()
    {
        const string format = "{0,-11} | {1}";
        foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.AllCultures))
        {
            Console.WriteLine(format, ci.Name, ci.DateTimeFormat.ShortDatePattern);
        }
    }
}