23 using System.Globalization;
26 namespace Ntp.Analyzer.Monitor.Server.TextCommand
39 var builder =
new StringBuilder();
41 builder.Append(
"Daemon was started ");
44 builder.Append(TimeZone.CurrentTimeZone.StandardName);
49 builder.Append(
"Uptime ");
50 builder.Append(FormatTimespan(runtime));
53 return builder.ToString();
60 if (time.TotalDays >= 1 && time.TotalDays < 2)
64 else if (time.TotalDays >= 2)
66 days = time.TotalDays.ToString(CultureInfo.InvariantCulture) +
" days ";
75 if (time.Hours >= 1 && time.Hours < 2)
79 else if (time.Hours >= 2)
81 hours = time.Hours.ToString(CultureInfo.InvariantCulture) +
" hours ";
90 if (time.Minutes >= 1 && time.Minutes < 2)
92 minutes =
"1 minute ";
94 else if (time.Minutes >= 2)
96 minutes = time.Minutes.ToString(CultureInfo.InvariantCulture) +
" minutes ";
100 minutes =
string.Empty;
105 if (time.Seconds >= 1 && time.Seconds < 2)
107 seconds =
"1 second";
109 else if (time.Seconds >= 2)
111 seconds = time.Seconds.ToString(CultureInfo.InvariantCulture) +
" seconds";
115 seconds =
string.Empty;
118 return string.Concat(days, hours, minutes, seconds);
override string ExecuteTextCommand()
UptimeCommand(string[] args)
string FormatTimespan(TimeSpan time)
static DateTime StartupTime