https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0ca929791ae4cbaff4ad6…
commit 0ca929791ae4cbaff4ad6440636305b7f833b6d1
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Sat May 18 14:46:04 2019 +0200
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Sat May 18 14:46:54 2019 +0200
[NET] Implement proper output of logon hour ranges in the USER command.
---
base/applications/network/net/cmdUser.c | 51 ++++++++++++++++++++++++++++++---
1 file changed, 47 insertions(+), 4 deletions(-)
diff --git a/base/applications/network/net/cmdUser.c
b/base/applications/network/net/cmdUser.c
index 5ebef48b127..f697d4570b4 100644
--- a/base/applications/network/net/cmdUser.c
+++ b/base/applications/network/net/cmdUser.c
@@ -10,6 +10,9 @@
#include "net.h"
+#define SECONDS_PER_DAY (60 * 60 * 24)
+#define SECONDS_PER_HOUR (60 * 60)
+
typedef struct _COUNTY_TABLE
{
DWORD dwCountryCode;
@@ -147,6 +150,31 @@ PrintDateTime(DWORD dwSeconds)
}
+static
+VOID
+PrintLocalTime(DWORD dwSeconds)
+{
+ LARGE_INTEGER Time;
+ FILETIME FileTime;
+ SYSTEMTIME SystemTime;
+ WCHAR TimeBuffer[80];
+
+ RtlSecondsSince1970ToTime(dwSeconds, &Time);
+ FileTime.dwLowDateTime = Time.u.LowPart;
+ FileTime.dwHighDateTime = Time.u.HighPart;
+ FileTimeToSystemTime(&FileTime, &SystemTime);
+
+ GetTimeFormatW(LOCALE_USER_DEFAULT,
+ TIME_NOSECONDS,
+ &SystemTime,
+ NULL,
+ TimeBuffer,
+ ARRAYSIZE(TimeBuffer));
+
+ ConPrintf(StdOut, L"%s", TimeBuffer);
+}
+
+
static
DWORD
GetTimeInSeconds(VOID)
@@ -217,7 +245,7 @@ PrintLogonHours(
INT nPaddedLength)
{
DWORD dwUnitsPerDay, dwBitNumber, dwSecondsPerUnit;
- DWORD dwStartTime, dwEndTime;
+ DWORD dwStartTime, dwEndTime, dwStartDay, dwEndDay;
BOOL bBitValue, bFirst = TRUE;
if ((dwUnitsPerWeek == 0) ||
@@ -230,7 +258,7 @@ PrintLogonHours(
((dwUnitsPerDay / 24) > 6))
return;
- dwSecondsPerUnit = (24 * 60 * 60) / dwUnitsPerDay;
+ dwSecondsPerUnit = (SECONDS_PER_DAY) / dwUnitsPerDay;
for (dwBitNumber = 0; dwBitNumber < dwUnitsPerWeek; dwBitNumber++)
{
@@ -251,14 +279,29 @@ PrintLogonHours(
if (!bFirst)
PrintPadding(L' ', nPaddedLength);
- if (dwStartTime == 0 && dwEndTime == (60 * 60 * 24 * 7))
+ if (dwStartTime == 0 && dwEndTime == (SECONDS_PER_DAY * 7))
{
PrintMessageString(4302);
ConPuts(StdOut, L"\n");
}
else
{
- ConPrintf(StdOut, L"%lu - %lu\n", dwStartTime, dwEndTime);
+ dwStartDay = dwStartTime / SECONDS_PER_DAY;
+ dwEndDay = (dwEndTime / SECONDS_PER_DAY) % 7;
+
+ PrintMessageString(4307 + dwStartDay);
+ ConPuts(StdOut, L" ");
+ PrintLocalTime((dwStartTime % SECONDS_PER_DAY) + SECONDS_PER_HOUR);
+
+ ConPrintf(StdOut, L" - ");
+ if (dwStartDay != dwEndDay)
+ {
+ PrintMessageString(4307 + dwEndDay);
+ ConPuts(StdOut, L" ");
+ }
+
+ PrintLocalTime((dwEndTime % SECONDS_PER_DAY) + SECONDS_PER_HOUR);
+ ConPuts(StdOut, L"\n");
}
bFirst = FALSE;