Open lockheed opened 3 years ago
I'm assuming you're in UTC+1 (CET), and that the plugin is displaying UTC
That's correct. But all other plugins display CET.
All other plugins is false https://github.com/jellyfin/jellyfin-plugin-playbackreporting/issues/24, but could you point to a plugin that actually does show the expected time?
Playback Reporting (I think that's built-in). "Activity" and anything else displaying timestamps in the dashboard. (I realised these are not plugins) Those display timestamps correctly, plus they display it in European style, not AM/PM.
Both web client and server are in the same timezone UTC+1 (CET).
Looking through the codebase, which I'll freely admit I'm not too familiar with, it looks like ReportHelper.cs#L16-L33 are where this might be going wrong.
public static string? ConvertToString<T>(T value, ReportFieldType fieldType)
{
if (value == null)
{
return string.Empty;
}
return fieldType switch
{
ReportFieldType.Boolean | ReportFieldType.Int | ReportFieldType.String => value.ToString(),
ReportFieldType.Date => string.Format(CultureInfo.InvariantCulture, "{0:d}", value),
ReportFieldType.Time => string.Format(CultureInfo.InvariantCulture, "{0:t}", value),
ReportFieldType.DateTime => string.Format(CultureInfo.InvariantCulture, "{0:g}", value),
ReportFieldType.Minutes => string.Format(CultureInfo.InvariantCulture, "{0}mn", value),
_ when value is Guid guid => guid.ToString("N", CultureInfo.InvariantCulture),
_ => value.ToString()
};
}
Using the CultureInfo.InvariantCulture
calls brings whatever you have into UTC I believe.
There's several ways resolving this could be approached. Perhaps someone could pitch in here to see what would best suit this codebase. Unfortunately I don't have an environment where I could build and test out solutions hence my input will limit itself to suggesting approaches as opposed to providing a suitable patch.
Instead of using the InvariantCulture why not rely on the CultureInfo provided by the environment? Is it not suitable here? Another thing to consider is the serialization and desirialization of the dates where timezones get involved. Is TimeZoneInfo.Local set correctly in the environment?
There's a decent article in the Ms Docs that covers this providing handy examples.
Roughly here's a rundown that could get us on the right path:
// Parse the date.
DateTime parsedDate = DateTime.ParseExact(dateValue, "o",
DateTimeFormatInfo.InvariantInfo);
// Convert it to local time.
DateTime restoredDate = parsedDate.ToLocalTime();
// Display information on the date and time.
Console.WriteLine("Deserialized date: {0:F}", restoredDate);
Console.WriteLine("Current Culture: {0}",
CultureInfo.CurrentCulture.Name);
Console.WriteLine("Time Zone: {0}",
TimeZoneInfo.Local.DisplayName);
// The above could display the following output:
// Deserialized date: lundi 18 août 2014 17:16:35
// Current Culture: fr-FR
// Time Zone: (UTC+01:00) Brussels, Copenhagen, Madrid, Paris
Hope this helps.
mine displays in 24 hour format but is 3 hours ahead
My reports are also in UTC. Just to confirm - has there been no update to the plugin to either have a timezone setting or to import the Jellyfin time zone setting?
2 hours back
time zone me: UTC +2
Jellyfin has the correct time and timezone (linked to /etc/localtime). Also, timestamps in Dashboard/Activity section are correct. However, in Reports plugin, the times are: a - 1 hour behind b - in AM/PM format, even though system as well as Jellyfin are set for 24h format
Jellyfin 10.6.4 run as docker container. Reports version 10.0.0.0