2 Main file for time, timezone, and date shell level 2 and shell level 3 functions.
4 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "UefiShellLevel2CommandsLib.h"
18 Determine if String is a valid representation for a time or date.
20 @param[in] String The pointer to the string to test.
21 @param[in] Char The delimeter character.
22 @param[in] Min The minimum value allowed.
23 @param[in] Max The maximum value allowed.
24 @param[in] MinusOk Whether negative numbers are permitted.
26 @retval TRUE String is a valid representation.
27 @retval FALSE String is invalid.
31 InternalIsTimeLikeString (
32 IN CONST CHAR16
*String
,
36 IN CONST BOOLEAN MinusOk
44 // A single minus is ok.
46 if (*String
== L
'-') {
52 // the first char must be numeric.
54 if (!ShellIsDecimalDigitCharacter(*String
)) {
58 // loop through the characters and use the lib function
60 for ( ; String
!= NULL
&& *String
!= CHAR_NULL
; String
++){
61 if (*String
== Char
) {
68 if (!ShellIsDecimalDigitCharacter(*String
)) {
79 Verify that the DateString is valid and if so set that as the current
82 @param[in] DateString The pointer to a string representation of the date.
84 @retval SHELL_INVALID_PARAMETER DateString was NULL.
85 @retval SHELL_INVALID_PARAMETER DateString was mis-formatted.
86 @retval SHELL_SUCCESS The operation was successful.
91 IN CONST CHAR16
*DateString
96 CHAR16
*DateStringCopy
;
100 if (!InternalIsTimeLikeString(DateString
, L
'/', 2, 2, FALSE
)) {
101 return (SHELL_INVALID_PARAMETER
);
104 Status
= gRT
->GetTime(&TheTime
, NULL
);
105 ASSERT_EFI_ERROR(Status
);
107 DateStringCopy
= NULL
;
108 DateStringCopy
= StrnCatGrow(&DateStringCopy
, NULL
, DateString
, 0);
109 if (DateStringCopy
== NULL
) {
110 return (SHELL_OUT_OF_RESOURCES
);
112 Walker
= DateStringCopy
;
114 TheTime
.Month
= 0xFF;
116 TheTime
.Year
= 0xFFFF;
118 Walker1
= StrStr(Walker
, L
"/");
119 if (Walker1
!= NULL
&& *Walker1
== L
'/') {
120 *Walker1
= CHAR_NULL
;
123 TheTime
.Month
= (UINT8
)ShellStrToUintn (Walker
);
124 if (Walker1
!= NULL
) {
125 Walker
= Walker1
+ 1;
127 Walker1
= Walker
!=NULL
?StrStr(Walker
, L
"/"):NULL
;
128 if (Walker1
!= NULL
&& *Walker1
== L
'/') {
129 *Walker1
= CHAR_NULL
;
131 if (Walker
!= NULL
&& Walker
[0] != CHAR_NULL
) {
132 TheTime
.Day
= (UINT8
)ShellStrToUintn (Walker
);
133 if (Walker1
!= NULL
) {
134 Walker
= Walker1
+ 1;
136 Walker1
= Walker
!=NULL
?StrStr(Walker
, L
"/"):NULL
;
137 if (Walker1
!= NULL
&& *Walker1
== L
'/') {
138 *Walker1
= CHAR_NULL
;
140 if (Walker
!= NULL
&& Walker
[0] != CHAR_NULL
) {
141 TheTime
.Year
= (UINT16
)ShellStrToUintn (Walker
);
145 if (TheTime
.Year
< 100) {
146 if (TheTime
.Year
>= 98) {
147 TheTime
.Year
= (UINT16
)(1900 + TheTime
.Year
);
149 TheTime
.Year
= (UINT16
)(2000 + TheTime
.Year
);
153 Status
= gRT
->SetTime(&TheTime
);
155 if (!EFI_ERROR(Status
)){
156 return (SHELL_SUCCESS
);
158 return (SHELL_INVALID_PARAMETER
);
162 Function for 'date' command.
164 @param[in] ImageHandle Handle to the Image (NULL if Internal).
165 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
169 ShellCommandRunDate (
170 IN EFI_HANDLE ImageHandle
,
171 IN EFI_SYSTEM_TABLE
*SystemTable
177 CHAR16
*ProblemParam
;
178 SHELL_STATUS ShellStatus
;
180 ShellStatus
= SHELL_SUCCESS
;
184 // initialize the shell lib (we must be in non-auto-init...)
186 Status
= ShellInitialize();
187 ASSERT_EFI_ERROR(Status
);
190 // parse the command line
192 Status
= ShellCommandLineParse (SfoParamList
, &Package
, &ProblemParam
, TRUE
);
193 if (EFI_ERROR(Status
)) {
194 if (Status
== EFI_VOLUME_CORRUPTED
&& ProblemParam
!= NULL
) {
195 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellLevel2HiiHandle
, ProblemParam
);
196 FreePool(ProblemParam
);
197 ShellStatus
= SHELL_INVALID_PARAMETER
;
205 if (ShellCommandLineGetFlag(Package
, L
"-?")) {
207 } else if (ShellCommandLineGetRawValue(Package
, 2) != NULL
) {
208 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_MANY
), gShellLevel2HiiHandle
);
209 ShellStatus
= SHELL_INVALID_PARAMETER
;
212 // If there are 0 value parameters, then print the current date
213 // else If there are any value paramerers, then print error
215 if (ShellCommandLineGetRawValue(Package
, 1) == NULL
) {
217 // get the current date
219 Status
= gRT
->GetTime(&TheTime
, NULL
);
220 ASSERT_EFI_ERROR(Status
);
223 // ShellPrintEx the date in SFO or regular format
225 if (ShellCommandLineGetFlag(Package
, L
"-sfo")) {
226 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_DATE_SFO_FORMAT
), gShellLevel2HiiHandle
, TheTime
.Month
, TheTime
.Day
, TheTime
.Year
);
228 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_DATE_FORMAT
), gShellLevel2HiiHandle
, TheTime
.Month
, TheTime
.Day
, TheTime
.Year
);
231 if (PcdGet8(PcdShellSupportLevel
) == 2) {
232 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_MANY
), gShellLevel2HiiHandle
);
233 ShellStatus
= SHELL_INVALID_PARAMETER
;
236 // perform level 3 operation here.
238 ShellStatus
= CheckAndSetDate(ShellCommandLineGetRawValue(Package
, 1));
239 if (ShellStatus
!= SHELL_SUCCESS
) {
240 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellLevel2HiiHandle
, ShellCommandLineGetRawValue(Package
, 1));
241 ShellStatus
= SHELL_INVALID_PARAMETER
;
248 // free the command line package
250 ShellCommandLineFreeVarList (Package
);
255 return (ShellStatus
);
259 // Note "-tz" is invalid for this (non-interactive) version of 'time'.
261 STATIC CONST SHELL_PARAM_ITEM TimeParamList2
[] = {
266 STATIC CONST SHELL_PARAM_ITEM TimeParamList3
[] = {
273 Verify that the TimeString is valid and if so set that as the current
276 @param[in] TimeString The pointer to a string representation of the time.
277 @param[in] Tz The value to set for TimeZone.
278 @param[in] Daylight The value to set for Daylight.
280 @retval SHELL_INVALID_PARAMETER TimeString was NULL.
281 @retval SHELL_INVALID_PARAMETER TimeString was mis-formatted.
282 @retval SHELL_SUCCESS The operation was successful.
287 IN CONST CHAR16
*TimeString
,
289 IN CONST UINT8 Daylight
294 CHAR16
*TimeStringCopy
;
298 if (TimeString
!= NULL
&& !InternalIsTimeLikeString(TimeString
, L
':', 1, 2, FALSE
)) {
299 return (SHELL_INVALID_PARAMETER
);
301 if (((Daylight
& (EFI_TIME_IN_DAYLIGHT
|EFI_TIME_ADJUST_DAYLIGHT
)) != Daylight
)) {
302 return (SHELL_INVALID_PARAMETER
);
305 Status
= gRT
->GetTime(&TheTime
, NULL
);
306 ASSERT_EFI_ERROR(Status
);
308 if (TimeString
!= NULL
) {
309 TimeStringCopy
= NULL
;
310 TimeStringCopy
= StrnCatGrow(&TimeStringCopy
, NULL
, TimeString
, 0);
311 Walker1
= TimeStringCopy
;
313 TheTime
.Minute
= 0xFF;
315 Walker2
= Walker1
!=NULL
?StrStr(Walker1
, L
":"):NULL
;
316 if (Walker2
!= NULL
&& *Walker2
== L
':') {
317 *Walker2
= CHAR_NULL
;
319 TheTime
.Hour
= (UINT8
)ShellStrToUintn (Walker1
);
320 if (Walker2
!= NULL
) {
321 Walker1
= Walker2
+ 1;
323 Walker2
= Walker1
!=NULL
?StrStr(Walker1
, L
":"):NULL
;
324 if (Walker2
!= NULL
&& *Walker2
== L
':') {
325 *Walker2
= CHAR_NULL
;
327 if (Walker1
!= NULL
&& Walker1
[0] != CHAR_NULL
) {
328 TheTime
.Minute
= (UINT8
)ShellStrToUintn (Walker1
);
329 if (Walker2
!= NULL
) {
330 Walker1
= Walker2
+ 1;
332 if (Walker1
!= NULL
&& Walker1
[0] != CHAR_NULL
) {
333 TheTime
.Second
= (UINT8
)ShellStrToUintn (Walker1
);
336 SHELL_FREE_NON_NULL(TimeStringCopy
);
340 if ((Tz
>= -1440 && Tz
<= 1440)||(Tz
== 0x7FF)) {
341 TheTime
.TimeZone
= Tz
;
344 TheTime
.Daylight
= Daylight
;
346 Status
= gRT
->SetTime(&TheTime
);
348 if (!EFI_ERROR(Status
)){
349 return (SHELL_SUCCESS
);
352 return (SHELL_INVALID_PARAMETER
);
356 Function for 'time' command.
358 @param[in] ImageHandle Handle to the Image (NULL if Internal).
359 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
363 ShellCommandRunTime (
364 IN EFI_HANDLE ImageHandle
,
365 IN EFI_SYSTEM_TABLE
*SystemTable
372 CHAR16
*ProblemParam
;
373 SHELL_STATUS ShellStatus
;
376 CONST CHAR16
*TempLocation
;
379 ShellStatus
= SHELL_SUCCESS
;
383 // Initialize variables
388 // initialize the shell lib (we must be in non-auto-init...)
390 Status
= ShellInitialize();
391 ASSERT_EFI_ERROR(Status
);
394 // parse the command line
396 if (PcdGet8(PcdShellSupportLevel
) == 2) {
397 Status
= ShellCommandLineParseEx (TimeParamList2
, &Package
, &ProblemParam
, TRUE
, TRUE
);
399 ASSERT(PcdGet8(PcdShellSupportLevel
) == 3);
400 Status
= ShellCommandLineParseEx (TimeParamList3
, &Package
, &ProblemParam
, TRUE
, TRUE
);
402 if (EFI_ERROR(Status
)) {
403 if (Status
== EFI_VOLUME_CORRUPTED
&& ProblemParam
!= NULL
) {
404 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellLevel2HiiHandle
, ProblemParam
);
405 FreePool(ProblemParam
);
406 ShellStatus
= SHELL_INVALID_PARAMETER
;
414 Status
= gRT
->GetTime(&TheTime
, NULL
);
415 ASSERT_EFI_ERROR(Status
);
416 if (ShellCommandLineGetFlag(Package
, L
"-?")) {
418 } else if (ShellCommandLineGetRawValue(Package
, 2) != NULL
) {
419 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_MANY
), gShellLevel2HiiHandle
);
420 ShellStatus
= SHELL_INVALID_PARAMETER
;
423 // If there are no parameters, then print the current time
425 if (ShellCommandLineGetRawValue(Package
, 1) == NULL
426 && !ShellCommandLineGetFlag(Package
, L
"-d")
427 && !ShellCommandLineGetFlag(Package
, L
"-tz")) {
429 // ShellPrintEx the current time
431 if (TheTime
.TimeZone
== 2047) {
434 TzMinutes
= (ABS(TheTime
.TimeZone
)) % 60;
441 STRING_TOKEN (STR_TIME_FORMAT
),
442 gShellLevel2HiiHandle
,
446 TheTime
.TimeZone
==2047?L
" ":(TheTime
.TimeZone
> 0?L
"-":L
"+"),
447 TheTime
.TimeZone
==2047?0:(ABS(TheTime
.TimeZone
)) / 60,
450 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_CRLF
), gShellLevel2HiiHandle
);
451 } else if (ShellCommandLineGetFlag(Package
, L
"-d") && ShellCommandLineGetValue(Package
, L
"-d") == NULL
) {
452 if (TheTime
.TimeZone
== 2047) {
455 TzMinutes
= (ABS(TheTime
.TimeZone
)) % 60;
462 STRING_TOKEN (STR_TIME_FORMAT
),
463 gShellLevel2HiiHandle
,
467 TheTime
.TimeZone
==2047?L
" ":(TheTime
.TimeZone
> 0?L
"-":L
"+"),
468 TheTime
.TimeZone
==2047?0:(ABS(TheTime
.TimeZone
)) / 60,
471 switch (TheTime
.Daylight
) {
473 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_TIME_DST0
), gShellLevel2HiiHandle
);
475 case EFI_TIME_ADJUST_DAYLIGHT
:
476 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_TIME_DST1
), gShellLevel2HiiHandle
);
478 case EFI_TIME_IN_DAYLIGHT
:
479 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_TIME_DST2
), gShellLevel2HiiHandle
);
481 case EFI_TIME_IN_DAYLIGHT
|EFI_TIME_ADJUST_DAYLIGHT
:
482 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_TIME_DST3
), gShellLevel2HiiHandle
);
485 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_UEFI_FUNC_ERROR
), gShellLevel2HiiHandle
, L
"gRT->GetTime", L
"TheTime.Daylight", TheTime
.Daylight
);
488 if (PcdGet8(PcdShellSupportLevel
) == 2) {
489 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_MANY
), gShellLevel2HiiHandle
);
490 ShellStatus
= SHELL_INVALID_PARAMETER
;
493 // perform level 3 operation here.
495 if ((TempLocation
= ShellCommandLineGetValue(Package
, L
"-tz")) != NULL
) {
496 if (TempLocation
[0] == L
'-') {
497 Tz
= (INT16
)(0 - ShellStrToUintn(++TempLocation
));
499 Tz
= (INT16
)ShellStrToUintn(TempLocation
);
501 if (!(Tz
>= -1440 && Tz
<= 1440) && Tz
!= 2047) {
502 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM_VAL
), gShellLevel2HiiHandle
, L
"-tz");
503 ShellStatus
= SHELL_INVALID_PARAMETER
;
507 // intentionally out of bounds value will prevent changing it...
511 TempLocation
= ShellCommandLineGetValue(Package
, L
"-d");
512 if (TempLocation
!= NULL
) {
513 Daylight
= (UINT8
)ShellStrToUintn(TempLocation
);
514 if (Daylight
!= 0 && Daylight
!= 1 && Daylight
!= 3) {
515 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM_VAL
), gShellLevel2HiiHandle
, L
"-d");
516 ShellStatus
= SHELL_INVALID_PARAMETER
;
520 // invalid = will not use
524 if (ShellStatus
== SHELL_SUCCESS
) {
525 ShellStatus
= CheckAndSetTime(ShellCommandLineGetRawValue(Package
, 1), Tz
, Daylight
);
526 if (ShellStatus
!= SHELL_SUCCESS
) {
527 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellLevel2HiiHandle
, ShellCommandLineGetRawValue(Package
, 1));
528 ShellStatus
= SHELL_INVALID_PARAMETER
;
537 // free the command line package
539 ShellCommandLineFreeVarList (Package
);
544 return (ShellStatus
);
549 EFI_STRING_ID StringId
;
552 STATIC CONST SHELL_PARAM_ITEM TimeZoneParamList2
[] = {
557 STATIC CONST SHELL_PARAM_ITEM TimeZoneParamList3
[] = {
564 STATIC CONST TIME_ZONE_ITEM TimeZoneList
[] = {
565 {720, STRING_TOKEN (STR_TIMEZONE_M12
)},
566 {660, STRING_TOKEN (STR_TIMEZONE_M11
)},
567 {600, STRING_TOKEN (STR_TIMEZONE_M10
)},
568 {540, STRING_TOKEN (STR_TIMEZONE_M9
)},
569 {480, STRING_TOKEN (STR_TIMEZONE_M8
)},
570 {420, STRING_TOKEN (STR_TIMEZONE_M7
)},
571 {360, STRING_TOKEN (STR_TIMEZONE_M6
)},
572 {300, STRING_TOKEN (STR_TIMEZONE_M5
)},
573 {270, STRING_TOKEN (STR_TIMEZONE_M430
)},
574 {240, STRING_TOKEN (STR_TIMEZONE_M4
)},
575 {210, STRING_TOKEN (STR_TIMEZONE_M330
)},
576 {180, STRING_TOKEN (STR_TIMEZONE_M3
)},
577 {120, STRING_TOKEN (STR_TIMEZONE_M2
)},
578 {60 , STRING_TOKEN (STR_TIMEZONE_M1
)},
579 {0 , STRING_TOKEN (STR_TIMEZONE_0
)},
580 {-60 , STRING_TOKEN (STR_TIMEZONE_P1
)},
581 {-120 , STRING_TOKEN (STR_TIMEZONE_P2
)},
582 {-180 , STRING_TOKEN (STR_TIMEZONE_P3
)},
583 {-210 , STRING_TOKEN (STR_TIMEZONE_P330
)},
584 {-240 , STRING_TOKEN (STR_TIMEZONE_P4
)},
585 {-270 , STRING_TOKEN (STR_TIMEZONE_P430
)},
586 {-300 , STRING_TOKEN (STR_TIMEZONE_P5
)},
587 {-330 , STRING_TOKEN (STR_TIMEZONE_P530
)},
588 {-345 , STRING_TOKEN (STR_TIMEZONE_P545
)},
589 {-360 , STRING_TOKEN (STR_TIMEZONE_P6
)},
590 {-390 , STRING_TOKEN (STR_TIMEZONE_P630
)},
591 {-420 , STRING_TOKEN (STR_TIMEZONE_P7
)},
592 {-480 , STRING_TOKEN (STR_TIMEZONE_P8
)},
593 {-540 , STRING_TOKEN (STR_TIMEZONE_P9
)},
594 {-570 , STRING_TOKEN (STR_TIMEZONE_P930
)},
595 {-600 , STRING_TOKEN (STR_TIMEZONE_P10
)},
596 {-660 , STRING_TOKEN (STR_TIMEZONE_P11
)},
597 {-720 , STRING_TOKEN (STR_TIMEZONE_P12
)},
598 {-780 , STRING_TOKEN (STR_TIMEZONE_P13
)},
599 {-840 , STRING_TOKEN (STR_TIMEZONE_P14
)}
603 Verify that the TimeZoneString is valid and if so set that as the current
606 @param[in] TimeZoneString The pointer to a string representation of the timezone.
608 @retval SHELL_INVALID_PARAMETER TimeZoneString was NULL.
609 @retval SHELL_INVALID_PARAMETER TimeZoneString was mis-formatted.
610 @retval SHELL_SUCCESS The operation was successful.
614 CheckAndSetTimeZone (
615 IN CONST CHAR16
*TimeZoneString
620 CHAR16
*TimeZoneCopy
;
625 if (TimeZoneString
== NULL
) {
626 return (SHELL_INVALID_PARAMETER
);
629 if (TimeZoneString
!= NULL
&& !InternalIsTimeLikeString(TimeZoneString
, L
':', 1, 1, TRUE
)) {
630 return (SHELL_INVALID_PARAMETER
);
633 Status
= gRT
->GetTime(&TheTime
, NULL
);
634 ASSERT_EFI_ERROR(Status
);
637 TimeZoneCopy
= StrnCatGrow(&TimeZoneCopy
, NULL
, TimeZoneString
, 0);
638 Walker
= TimeZoneCopy
;
639 Walker2
= StrStr(Walker
, L
":");
640 if (Walker2
!= NULL
&& *Walker2
== L
':') {
641 *Walker2
= CHAR_NULL
;
643 if (*Walker
== L
'-') {
644 TheTime
.TimeZone
= (INT16
)((ShellStrToUintn (++Walker
)) * 60);
646 TheTime
.TimeZone
= (INT16
)((ShellStrToUintn (Walker
)) * -60);
648 if (Walker2
!= NULL
) {
649 Walker
= Walker2
+ 1;
651 if (Walker
!= NULL
&& Walker
[0] != CHAR_NULL
) {
652 if (TheTime
.TimeZone
< 0) {
653 TheTime
.TimeZone
= (INT16
)(TheTime
.TimeZone
- (UINT8
)ShellStrToUintn (Walker
));
655 TheTime
.TimeZone
= (INT16
)(TheTime
.TimeZone
+ (UINT8
)ShellStrToUintn (Walker
));
659 Status
= EFI_INVALID_PARAMETER
;
662 ; LoopVar
< sizeof(TimeZoneList
) / sizeof(TimeZoneList
[0])
665 if (TheTime
.TimeZone
== TimeZoneList
[LoopVar
].TimeZone
) {
666 Status
= gRT
->SetTime(&TheTime
);
671 FreePool(TimeZoneCopy
);
673 if (!EFI_ERROR(Status
)){
674 return (SHELL_SUCCESS
);
676 return (SHELL_INVALID_PARAMETER
);
681 Function for 'timezone' command.
683 @param[in] ImageHandle Handle to the Image (NULL if Internal).
684 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
688 ShellCommandRunTimeZone (
689 IN EFI_HANDLE ImageHandle
,
690 IN EFI_SYSTEM_TABLE
*SystemTable
698 CHAR16
*ProblemParam
;
699 SHELL_STATUS ShellStatus
;
705 ShellStatus
= SHELL_SUCCESS
;
709 // initialize the shell lib (we must be in non-auto-init...)
711 Status
= ShellInitialize();
712 ASSERT_EFI_ERROR(Status
);
715 // parse the command line
717 if (PcdGet8(PcdShellSupportLevel
) == 2) {
718 Status
= ShellCommandLineParse (TimeZoneParamList2
, &Package
, &ProblemParam
, FALSE
);
720 ASSERT(PcdGet8(PcdShellSupportLevel
) == 3);
721 Status
= ShellCommandLineParseEx (TimeZoneParamList3
, &Package
, &ProblemParam
, FALSE
, TRUE
);
723 if (EFI_ERROR(Status
)) {
724 if (Status
== EFI_VOLUME_CORRUPTED
&& ProblemParam
!= NULL
) {
725 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellLevel2HiiHandle
, ProblemParam
);
726 FreePool(ProblemParam
);
727 ShellStatus
= SHELL_INVALID_PARAMETER
;
735 if (ShellCommandLineGetCount(Package
) > 1) {
736 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_MANY
), gShellLevel2HiiHandle
);
737 ShellStatus
= SHELL_INVALID_PARAMETER
;
738 } else if (ShellCommandLineGetFlag(Package
, L
"-?")) {
740 } else if (ShellCommandLineGetFlag(Package
, L
"-s")) {
741 if ((ShellCommandLineGetFlag(Package
, L
"-l")) || (ShellCommandLineGetFlag(Package
, L
"-f"))) {
742 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellLevel2HiiHandle
, L
"-l or -f");
743 ShellStatus
= SHELL_INVALID_PARAMETER
;
745 ASSERT(PcdGet8(PcdShellSupportLevel
) == 3);
746 if (ShellCommandLineGetValue(Package
, L
"-s") == NULL
) {
747 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_NO_VALUE
), gShellLevel2HiiHandle
, L
"-s");
748 ShellStatus
= SHELL_INVALID_PARAMETER
;
753 ShellStatus
= CheckAndSetTimeZone(ShellCommandLineGetValue(Package
, L
"-s"));
754 if (ShellStatus
!= SHELL_SUCCESS
) {
755 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellLevel2HiiHandle
, ShellCommandLineGetValue(Package
, L
"-s"));
756 ShellStatus
= SHELL_INVALID_PARAMETER
;
760 } else if (ShellCommandLineGetFlag(Package
, L
"-l")) {
762 // Print a list of all time zones
765 ; LoopVar
< sizeof(TimeZoneList
) / sizeof(TimeZoneList
[0])
768 ShellPrintHiiEx (-1, -1, NULL
, TimeZoneList
[LoopVar
].StringId
, gShellLevel2HiiHandle
);
772 // Get Current Time Zone Info
774 Status
= gRT
->GetTime(&TheTime
, NULL
);
775 ASSERT_EFI_ERROR(Status
);
777 if (TheTime
.TimeZone
!= 2047) {
780 ; LoopVar
< sizeof(TimeZoneList
) / sizeof(TimeZoneList
[0])
783 if (TheTime
.TimeZone
== TimeZoneList
[LoopVar
].TimeZone
) {
784 if (ShellCommandLineGetFlag(Package
, L
"-f")) {
786 // Print all info about current time zone
788 ShellPrintHiiEx (-1, -1, NULL
, TimeZoneList
[LoopVar
].StringId
, gShellLevel2HiiHandle
);
791 // Print basic info only
793 if (TheTime
.TimeZone
== 2047) {
796 TzMinutes
= (ABS(TheTime
.TimeZone
)) % 60;
803 STRING_TOKEN(STR_TIMEZONE_SIMPLE
),
804 gShellLevel2HiiHandle
,
805 TheTime
.TimeZone
==2047?0:(TheTime
.TimeZone
> 0?L
"-":L
"+"),
806 TheTime
.TimeZone
==2047?0:(ABS(TheTime
.TimeZone
)) / 60,
815 // Print basic info only
817 if (TheTime
.TimeZone
== 2047) {
820 TzMinutes
= (ABS(TheTime
.TimeZone
)) % 60;
826 STRING_TOKEN(STR_TIMEZONE_SIMPLE
),
827 gShellLevel2HiiHandle
,
828 TheTime
.TimeZone
==2047?0:(TheTime
.TimeZone
> 0?L
"-":L
"+"),
829 TheTime
.TimeZone
==2047?0:(ABS(TheTime
.TimeZone
)) / 60,
831 if (ShellCommandLineGetFlag(Package
, L
"-f")) {
832 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN(STR_TIMEZONE_NI
), gShellLevel2HiiHandle
);
837 // TimeZone was 2047 (unknown) from GetTime()
844 // free the command line package
846 ShellCommandLineFreeVarList (Package
);
848 return (ShellStatus
);