2 * TIME.C - time internal command.
7 * 07/08/1998 (John P. Price)
10 * 27-Jul-1998 (John P Price <linux-guru@gcfl.net>)
11 * added config.h include
13 * 09-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
14 * Added locale support.
16 * 19-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
17 * Unicode and redirection safe!
20 * 04-Feb-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
21 * Fixed time input bug.
23 * 30-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
24 * Remove all hardcode string to En.rc.
30 #ifdef INCLUDE_CMD_TIME
33 static BOOL
ParseTime (LPTSTR s
)
52 t
.wHour
= t
.wHour
* 10 + *p
- _T('0');
60 if (*p
!= cTimeSeparator
)
69 t
.wMinute
= t
.wMinute
* 10 + *p
- _T('0');
77 if (*p
!= cTimeSeparator
)
86 t
.wSecond
= t
.wSecond
* 10 + *p
- _T('0');
93 // get decimal separator
94 if (*p
== cDecimalSeparator
)
101 while (_istdigit(*p
))
103 // t.wMilliseconds = t.wMilliseconds * 10 + *p - _T('0');
106 // t.wMilliseconds *= 10;
110 /* special case: 12 hour format */
111 if (nTimeFormat
== 0)
113 if (_totupper(*s
) == _T('P'))
118 if ((_totupper(*s
) == _T('A')) && (t
.wHour
== 12))
124 if (t
.wHour
> 23 || t
.wMinute
> 60 || t
.wSecond
> 60 || t
.wMilliseconds
> 999)
133 INT
cmd_time (LPTSTR cmd
, LPTSTR param
)
139 INT nTimeString
= -1;
141 if (!_tcsncmp (param
, _T("/?"), 2))
143 ConOutResPaging(TRUE
,STRING_TIME_HELP1
);
149 /* build parameter array */
150 arg
= split (param
, &argc
, FALSE
);
152 /* check for options */
153 for (i
= 0; i
< argc
; i
++)
155 if (_tcsicmp (arg
[i
], _T("/t")) == 0)
158 if ((*arg
[i
] != _T('/')) && (nTimeString
== -1))
162 if (nTimeString
== -1)
173 if (nTimeString
== -1)
177 ConOutResPuts(STRING_TIME_HELP2
);
182 DebugPrintf (_T("\'%s\'\n"), s
);
185 while (*s
&& s
[_tcslen (s
) - 1] < _T(' '))
186 s
[_tcslen(s
) - 1] = _T('\0');
196 if (ParseTime (arg
[nTimeString
]))
202 /* force input the next time around. */
206 ConErrResPuts(STRING_TIME_ERROR1
);