GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — reactos/base/shell/cmd/time.c at master · reactos/reactos Expand file tree/ Copy pathtime.cMore file actions 213 lines (179 loc) · 4.09 KB / Copy pathtime.cFile metadata and controls213 lines (179 loc) · 4.09 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 /* * TIME.C - time internal command. * * * History: * * 07/08/1998 (John P. Price) * started. * * 27-Jul-1998 (John P Price <[email protected]>) * added config.h include * * 09-Jan-1999 (Eric Kohl) * Added locale support. * * 19-Jan-1999 (Eric Kohl) * Unicode and redirection safe! * Added "/t" option. * * 04-Feb-1999 (Eric Kohl) * Fixed time input bug. * * 30-Apr-2005 (Magnus Olsen <[email protected]>) * Remove all hardcoded strings in En.rc. */ #include "precomp.h" #ifdef INCLUDE_CMD_TIME static BOOL ParseTime (LPTSTR s) { SYSTEMTIME t; LPTSTR p = s; if (!*s) return TRUE; GetLocalTime (&t); t.wHour = 0; t.wMinute = 0; t.wSecond = 0; t.wMilliseconds = 0; // first get hour if (_istdigit(*p)) { while (_istdigit(*p)) { t.wHour = t.wHour * 10 + *p - _T('0'); p++; } } else return FALSE; // get time separator if (*p != cTimeSeparator) return FALSE; p++; // now get minutes if (_istdigit(*p)) { while (_istdigit(*p)) { t.wMinute = t.wMinute * 10 + *p - _T('0'); p++; } } else return FALSE; // get time separator if (*p != cTimeSeparator) return FALSE; p++; // now get seconds if (_istdigit(*p)) { while (_istdigit(*p)) { t.wSecond = t.wSecond * 10 + *p - _T('0'); p++; } } else return FALSE; // get decimal separator if (*p == cDecimalSeparator) { p++; // now get hundreths if (_istdigit(*p)) { while (_istdigit(*p)) { // t.wMilliseconds = t.wMilliseconds * 10 + *p - _T('0'); p++; } // t.wMilliseconds *= 10; } } /* special case: 12 hour format */ if (nTimeFormat == 0) { if (_totupper(*s) == _T('P')) { t.wHour += 12; } if ((_totupper(*s) == _T('A')) && (t.wHour == 12)) { t.wHour = 0; } } if (t.wHour > 23 || t.wMinute > 60 || t.wSecond > 60 || t.wMilliseconds > 999) return FALSE; SetLocalTime (&t); return TRUE; } INT cmd_time(LPTSTR param) { LPTSTR* arg; INT argc; INT i; INT nTimeString = -1; TCHAR szTime[40]; if (!_tcsncmp(param, _T("/?"), 2)) { ConOutResPaging(TRUE, STRING_TIME_HELP1); return 0; } nErrorLevel = 0; /* Build the parameter array */ arg = split(param, &argc, FALSE, FALSE); /* Check for options */ for (i = 0; i < argc; i++) { if (bEnableExtensions && (_tcsicmp(arg[i], _T("/T")) == 0)) { /* Display current time in short format */ SYSTEMTIME st; GetLocalTime(&st); FormatTime(szTime, &st); ConOutPrintf(_T("%s\n"), szTime); freep(arg); return 0; } if ((*arg[i] != _T('/')) && (nTimeString == -1)) nTimeString = i; } if (nTimeString == -1) { ConOutResPuts(STRING_TIME_NOW); ConOutPrintf(_T("%s\n"), GetTimeString()); } while (TRUE) { if (nTimeString == -1) { ConOutResPuts(STRING_TIME_HELP2); ConInString(szTime, ARRAYSIZE(szTime)); TRACE("\'%s\'\n", debugstr_aw(szTime)); while (*szTime && szTime[_tcslen(szTime) - 1] < _T(' ')) szTime[_tcslen(szTime) - 1] = _T('\0'); if (ParseTime(szTime)) { freep(arg); return 0; } } else { if (ParseTime(arg[nTimeString])) { freep(arg); return 0; } /* Force input the next time around */ nTimeString = -1; } ConErrResPuts(STRING_TIME_ERROR); nErrorLevel = 1; } freep(arg); return 0; } #endif |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |