mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 21:56:06 +00:00
[NET] Implement proper output of logon hour ranges in the USER command.
This commit is contained in:
parent
f3c71baa0c
commit
0ca929791a
1 changed files with 47 additions and 4 deletions
|
@ -10,6 +10,9 @@
|
||||||
|
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
|
||||||
|
#define SECONDS_PER_DAY (60 * 60 * 24)
|
||||||
|
#define SECONDS_PER_HOUR (60 * 60)
|
||||||
|
|
||||||
typedef struct _COUNTY_TABLE
|
typedef struct _COUNTY_TABLE
|
||||||
{
|
{
|
||||||
DWORD dwCountryCode;
|
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
|
static
|
||||||
DWORD
|
DWORD
|
||||||
GetTimeInSeconds(VOID)
|
GetTimeInSeconds(VOID)
|
||||||
|
@ -217,7 +245,7 @@ PrintLogonHours(
|
||||||
INT nPaddedLength)
|
INT nPaddedLength)
|
||||||
{
|
{
|
||||||
DWORD dwUnitsPerDay, dwBitNumber, dwSecondsPerUnit;
|
DWORD dwUnitsPerDay, dwBitNumber, dwSecondsPerUnit;
|
||||||
DWORD dwStartTime, dwEndTime;
|
DWORD dwStartTime, dwEndTime, dwStartDay, dwEndDay;
|
||||||
BOOL bBitValue, bFirst = TRUE;
|
BOOL bBitValue, bFirst = TRUE;
|
||||||
|
|
||||||
if ((dwUnitsPerWeek == 0) ||
|
if ((dwUnitsPerWeek == 0) ||
|
||||||
|
@ -230,7 +258,7 @@ PrintLogonHours(
|
||||||
((dwUnitsPerDay / 24) > 6))
|
((dwUnitsPerDay / 24) > 6))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dwSecondsPerUnit = (24 * 60 * 60) / dwUnitsPerDay;
|
dwSecondsPerUnit = (SECONDS_PER_DAY) / dwUnitsPerDay;
|
||||||
|
|
||||||
for (dwBitNumber = 0; dwBitNumber < dwUnitsPerWeek; dwBitNumber++)
|
for (dwBitNumber = 0; dwBitNumber < dwUnitsPerWeek; dwBitNumber++)
|
||||||
{
|
{
|
||||||
|
@ -251,14 +279,29 @@ PrintLogonHours(
|
||||||
if (!bFirst)
|
if (!bFirst)
|
||||||
PrintPadding(L' ', nPaddedLength);
|
PrintPadding(L' ', nPaddedLength);
|
||||||
|
|
||||||
if (dwStartTime == 0 && dwEndTime == (60 * 60 * 24 * 7))
|
if (dwStartTime == 0 && dwEndTime == (SECONDS_PER_DAY * 7))
|
||||||
{
|
{
|
||||||
PrintMessageString(4302);
|
PrintMessageString(4302);
|
||||||
ConPuts(StdOut, L"\n");
|
ConPuts(StdOut, L"\n");
|
||||||
}
|
}
|
||||||
else
|
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;
|
bFirst = FALSE;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue