diff --git a/DTLib/Logging/FileLogger.cs b/DTLib/Logging/FileLogger.cs index f012a22..6b73ad3 100644 --- a/DTLib/Logging/FileLogger.cs +++ b/DTLib/Logging/FileLogger.cs @@ -11,7 +11,7 @@ public class FileLogger : IDisposable } public FileLogger(string dir, string programName) - : this($"{dir}{Путь.Разд}{programName}_{DateTime.Now.ToString(MyTimeFormat.Instance)}.log") { } + : this($"{dir}{Путь.Разд}{programName}_{DateTime.Now.ToString(MyTimeFormat.ForFileNames)}.log") { } public string LogfileName { get; protected set; } public System.IO.FileStream LogfileStream { get; protected set; } @@ -22,7 +22,7 @@ public class FileLogger : IDisposable { lock (LogfileStream) { - LastLogMessageTime = DateTime.Now.ToString(MyTimeFormat.Instance); + LastLogMessageTime = DateTime.Now.ToString(MyTimeFormat.ForText); LogfileStream.WriteByte('['.ToByte()); LogfileStream.Write(LastLogMessageTime.ToBytes()); LogfileStream.Write("]: ".ToBytes()); diff --git a/DTLib/Logging/Tester.cs b/DTLib/Logging/Tester.cs index ce7e99d..36709e9 100644 --- a/DTLib/Logging/Tester.cs +++ b/DTLib/Logging/Tester.cs @@ -13,6 +13,6 @@ public static class Tester operation(); clock.Stop(); double time=(double)(clock.ElapsedTicks)/Stopwatch.Frequency/repeats; - Log("y",$"operation ","b",op_name,"y"," lasted ","b",time.ToString(MyTimeFormat.Instance),"y"," seconds"); + Log("y",$"operation ","b",op_name,"y"," lasted ","b",time.ToString(MyTimeFormat.ForText),"y"," seconds"); } } \ No newline at end of file diff --git a/DTLib/MyTimeFormat.cs b/DTLib/MyTimeFormat.cs index 677db5b..765b5c8 100644 --- a/DTLib/MyTimeFormat.cs +++ b/DTLib/MyTimeFormat.cs @@ -1,12 +1,7 @@ namespace DTLib; -public class MyTimeFormat : IFormatProvider +public static class MyTimeFormat { - public static MyTimeFormat Instance=new(); - public object GetFormat(Type formatType) - { - if(formatType==typeof(DateTime)) - return "yyyy-MM-dd_HH-mm-ss+zz"; - else throw new FormatException(); - } + public const string ForFileNames="yyyy.MM.dd_HH-mm-ss_zz"; + public const string ForText="yyyy.MM.dd HH:mm:ss zz"; } \ No newline at end of file