Skip to content

Commit ed2687b

Browse files
committed
Add culture options for formatting timestamps
1 parent 3976176 commit ed2687b

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/C3D/Extensions/Logging/Xunit/XunitLoggerOptions.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Microsoft.Extensions.Logging;
2+
using System.Globalization;
23

34
namespace C3D.Extensions.Xunit.Logging;
45

@@ -26,6 +27,8 @@ public XunitLoggerOptions(TimeProvider timeProvider) : this(timeProvider.GetUtcN
2627
private int? prefixLength;
2728
private string? timeStampFormat;
2829

30+
public System.Globalization.CultureInfo? Culture { get; set; }
31+
2932
public XunitLoggerTimeStamp TimeStamp { get; set; } = XunitLoggerTimeStamp.None;
3033
public string TimeStampFormat {
3134
get => timeStampFormat ?? TimeStamp switch
@@ -43,8 +46,8 @@ public string TimeStampFormat {
4346

4447
private string? DefaultTimeStamp() => TimeStamp switch
4548
{
46-
XunitLoggerTimeStamp.DateTime => GetUtcNow().ToString(TimeStampFormat),
47-
XunitLoggerTimeStamp.Offset => (GetUtcNow() - LogStart).ToString(TimeStampFormat),
49+
XunitLoggerTimeStamp.DateTime => GetUtcNow().ToString(TimeStampFormat, Culture ?? CultureInfo.CurrentCulture),
50+
XunitLoggerTimeStamp.Offset => (GetUtcNow() - LogStart).ToString(TimeStampFormat, Culture ?? CultureInfo.CurrentCulture),
4851
_ => null
4952
};
5053
#endregion

0 commit comments

Comments
 (0)