X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=ShellPkg%2FLibrary%2FUefiShellLevel2CommandsLib%2FTimeDate.c;h=28a3c3609959dc1b077be92726e45ff8ec2247a4;hp=f2f2e60b7cc02439c3f17860d1d537f0d008cb8d;hb=099e8ff5d2876b1d1606c3424114969946c15173;hpb=532691c8ba90e5022174503ab0781322c6f79cab diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c index f2f2e60b7c..28a3c36099 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c @@ -1,7 +1,8 @@ /** @file Main file for time, timezone, and date shell level 2 and shell level 3 functions. - Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+ Copyright (c) 2012 - 2015, Hewlett-Packard Development Company, L.P.
+ Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -103,7 +104,7 @@ CheckAndSetDate ( Status = gRT->GetTime(&TheTime, NULL); if (EFI_ERROR(Status)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"gRT->GetTime", Status); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"date", L"gRT->GetTime", Status); return (SHELL_DEVICE_ERROR); } @@ -196,7 +197,7 @@ ShellCommandRunDate ( Status = ShellCommandLineParse (SfoParamList, &Package, &ProblemParam, TRUE); if (EFI_ERROR(Status)) { if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, ProblemParam); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"date", ProblemParam); FreePool(ProblemParam); ShellStatus = SHELL_INVALID_PARAMETER; } else { @@ -209,7 +210,7 @@ ShellCommandRunDate ( if (ShellCommandLineGetFlag(Package, L"-?")) { ASSERT(FALSE); } else if (ShellCommandLineGetRawValue(Package, 2) != NULL) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"date"); ShellStatus = SHELL_INVALID_PARAMETER; } else { // @@ -221,19 +222,28 @@ ShellCommandRunDate ( // get the current date // Status = gRT->GetTime(&TheTime, NULL); - ASSERT_EFI_ERROR(Status); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"date", L"gRT->GetTime", Status); + return (SHELL_DEVICE_ERROR); + } // // ShellPrintEx the date in SFO or regular format // if (ShellCommandLineGetFlag(Package, L"-sfo")) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DATE_SFO_FORMAT), gShellLevel2HiiHandle, TheTime.Month, TheTime.Day, TheTime.Year); + // + // Match UEFI Shell spec: + // ShellCommand,"date" + // Date,"DD","MM","YYYY" + // + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_SFO_HEADER), gShellLevel2HiiHandle, L"date"); + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DATE_SFO_FORMAT), gShellLevel2HiiHandle, TheTime.Day, TheTime.Month, TheTime.Year); } else { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DATE_FORMAT), gShellLevel2HiiHandle, TheTime.Month, TheTime.Day, TheTime.Year); } } else { if (PcdGet8(PcdShellSupportLevel) == 2) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"date"); ShellStatus = SHELL_INVALID_PARAMETER; } else { // @@ -246,7 +256,7 @@ ShellCommandRunDate ( ShellStatus = CheckAndSetDate(Param1); } if (ShellStatus != SHELL_SUCCESS) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, Param1); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"date", Param1); ShellStatus = SHELL_INVALID_PARAMETER; } } @@ -312,7 +322,10 @@ CheckAndSetTime ( } Status = gRT->GetTime(&TheTime, NULL); - ASSERT_EFI_ERROR(Status); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"time", L"gRT->GetTime", Status); + return (SHELL_DEVICE_ERROR); + } if (TimeString != NULL) { TimeStringCopy = NULL; @@ -332,21 +345,35 @@ CheckAndSetTime ( Walker2 = Walker1!=NULL?StrStr(Walker1, L":"):NULL; if (Walker2 != NULL && *Walker2 == L':') { *Walker2 = CHAR_NULL; + TheTime.Second = (UINT8)0; + } + else if (Walker2 == NULL) { + TheTime.Second = (UINT8)0; } if (Walker1 != NULL && Walker1[0] != CHAR_NULL) { TheTime.Minute = (UINT8)ShellStrToUintn (Walker1); if (Walker2 != NULL) { Walker1 = Walker2 + 1; - } - if (Walker1 != NULL && Walker1[0] != CHAR_NULL) { - TheTime.Second = (UINT8)ShellStrToUintn (Walker1); + if (Walker1 != NULL && Walker1[0] != CHAR_NULL) { + TheTime.Second = (UINT8)ShellStrToUintn (Walker1); + } } } SHELL_FREE_NON_NULL(TimeStringCopy); } - if ((Tz >= -1440 && Tz <= 1440)||(Tz == 0x7FF)) { + if (Tz >= -1440 && Tz <= 1440) { + // + // EFI_TIME TimeZone is stored to meet the following calculation (see UEFI Spec): + // Localtime = UTC - TimeZone + // This means the sign must be changed for the user provided Tz. + // EX: User wants to set TimeZone to Pacific Standard Time, so runs + // time -tz -480 # set to UTC-08:00 + // To meet the calculation, the sign must be changed. + // + TheTime.TimeZone = -Tz; + } else if (Tz == EFI_UNSPECIFIED_TIMEZONE) { TheTime.TimeZone = Tz; } @@ -378,7 +405,6 @@ ShellCommandRunTime ( { EFI_STATUS Status; LIST_ENTRY *Package; - CHAR16 *Message; EFI_TIME TheTime; CHAR16 *ProblemParam; SHELL_STATUS ShellStatus; @@ -387,13 +413,11 @@ ShellCommandRunTime ( CONST CHAR16 *TempLocation; UINTN TzMinutes; - ShellStatus = SHELL_SUCCESS; - ProblemParam = NULL; - // // Initialize variables // - Message = NULL; + ShellStatus = SHELL_SUCCESS; + ProblemParam = NULL; // // initialize the shell lib (we must be in non-auto-init...) @@ -412,7 +436,7 @@ ShellCommandRunTime ( } if (EFI_ERROR(Status)) { if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, ProblemParam); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"time", ProblemParam); FreePool(ProblemParam); ShellStatus = SHELL_INVALID_PARAMETER; } else { @@ -423,11 +447,15 @@ ShellCommandRunTime ( // check for "-?" // Status = gRT->GetTime(&TheTime, NULL); - ASSERT_EFI_ERROR(Status); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"time", L"gRT->GetTime", Status); + return (SHELL_DEVICE_ERROR); + } + if (ShellCommandLineGetFlag(Package, L"-?")) { ASSERT(FALSE); } else if (ShellCommandLineGetRawValue(Package, 2) != NULL) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"time"); ShellStatus = SHELL_INVALID_PARAMETER; } else { // @@ -445,40 +473,61 @@ ShellCommandRunTime ( TzMinutes = (ABS(TheTime.TimeZone)) % 60; } - ShellPrintHiiEx ( - -1, - -1, - NULL, - STRING_TOKEN (STR_TIME_FORMAT), - gShellLevel2HiiHandle, - TheTime.Hour, - TheTime.Minute, - TheTime.Second, - TheTime.TimeZone==EFI_UNSPECIFIED_TIMEZONE?L" ":(TheTime.TimeZone > 0?L"-":L"+"), - TheTime.TimeZone==EFI_UNSPECIFIED_TIMEZONE?0:(ABS(TheTime.TimeZone)) / 60, - TzMinutes - ); - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_CRLF), gShellLevel2HiiHandle); + if (TheTime.TimeZone != EFI_UNSPECIFIED_TIMEZONE) { + ShellPrintHiiEx ( + -1, + -1, + NULL, + STRING_TOKEN (STR_TIME_FORMAT), + gShellLevel2HiiHandle, + TheTime.Hour, + TheTime.Minute, + TheTime.Second, + (TheTime.TimeZone > 0?L"-":L"+"), + ((ABS(TheTime.TimeZone)) / 60), + TzMinutes + ); + } else { + ShellPrintHiiEx ( + -1, + -1, + NULL, + STRING_TOKEN (STR_TIME_FORMAT_LOCAL), + gShellLevel2HiiHandle, + TheTime.Hour, + TheTime.Minute, + TheTime.Second + ); + } + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_CRLF), gShellLevel2HiiHandle); } else if (ShellCommandLineGetFlag(Package, L"-d") && ShellCommandLineGetValue(Package, L"-d") == NULL) { if (TheTime.TimeZone == EFI_UNSPECIFIED_TIMEZONE) { - TzMinutes = 0; + ShellPrintHiiEx ( + -1, + -1, + NULL, + STRING_TOKEN (STR_TIME_FORMAT_LOCAL), + gShellLevel2HiiHandle, + TheTime.Hour, + TheTime.Minute, + TheTime.Second + ); } else { TzMinutes = (ABS(TheTime.TimeZone)) % 60; + ShellPrintHiiEx ( + -1, + -1, + NULL, + STRING_TOKEN (STR_TIME_FORMAT), + gShellLevel2HiiHandle, + TheTime.Hour, + TheTime.Minute, + TheTime.Second, + (TheTime.TimeZone > 0?L"-":L"+"), + ((ABS(TheTime.TimeZone)) / 60), + TzMinutes + ); } - - ShellPrintHiiEx ( - -1, - -1, - NULL, - STRING_TOKEN (STR_TIME_FORMAT), - gShellLevel2HiiHandle, - TheTime.Hour, - TheTime.Minute, - TheTime.Second, - TheTime.TimeZone==EFI_UNSPECIFIED_TIMEZONE?L" ":(TheTime.TimeZone > 0?L"-":L"+"), - TheTime.TimeZone==EFI_UNSPECIFIED_TIMEZONE?0:(ABS(TheTime.TimeZone)) / 60, - TzMinutes - ); switch (TheTime.Daylight) { case 0: ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_TIME_DST0), gShellLevel2HiiHandle); @@ -493,24 +542,46 @@ ShellCommandRunTime ( ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_TIME_DST3), gShellLevel2HiiHandle); break; default: - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_ERROR), gShellLevel2HiiHandle, L"gRT->GetTime", L"TheTime.Daylight", TheTime.Daylight); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_ERROR), gShellLevel2HiiHandle, L"time", L"gRT->GetTime", L"TheTime.Daylight", TheTime.Daylight); } } else { if (PcdGet8(PcdShellSupportLevel) == 2) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"time"); ShellStatus = SHELL_INVALID_PARAMETER; } else { // // perform level 3 operation here. // if ((TempLocation = ShellCommandLineGetValue(Package, L"-tz")) != NULL) { - if (TempLocation[0] == L'-') { - Tz = (INT16)(0 - ShellStrToUintn(++TempLocation)); + if (StrniCmp (TempLocation, L"_local", StrLen (TempLocation)) == NULL) { + Tz = EFI_UNSPECIFIED_TIMEZONE; + } else if (TempLocation[0] == L'-') { + + Tz = (INT16) ShellStrToUintn (++TempLocation); + // + // When the argument of "time [-tz tz]" is not numeric, ShellStrToUintn() returns "-1". + // Here we can detect the argument error by checking the return of ShellStrToUintn(). + // + if (Tz == -1) { + Tz = 1441; //make it to be out of bounds value + } else { + Tz *= (-1); //sign convert + } } else { - Tz = (INT16)ShellStrToUintn(TempLocation); + if (TempLocation[0] == L'+') { + Tz = (INT16)ShellStrToUintn (++TempLocation); + } else { + Tz = (INT16)ShellStrToUintn (TempLocation); + } + // + // Detect the return of ShellStrToUintn() to make sure the argument is valid. + // + if (Tz == -1) { + Tz = 1441; //make it to be out of bounds value + } } if (!(Tz >= -1440 && Tz <= 1440) && Tz != EFI_UNSPECIFIED_TIMEZONE) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellLevel2HiiHandle, L"-tz"); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellLevel2HiiHandle, L"time", TempLocation, L"-tz"); ShellStatus = SHELL_INVALID_PARAMETER; } } else { @@ -522,8 +593,16 @@ ShellCommandRunTime ( TempLocation = ShellCommandLineGetValue(Package, L"-d"); if (TempLocation != NULL) { Daylight = (UINT8)ShellStrToUintn(TempLocation); + // + // The argument of "time [-d dl]" is unsigned, if the first character is '-', + // the argument is incorrect. That's because ShellStrToUintn() will skip past + // any '-' sign and convert what's next, forgetting the sign is here. + // + if (TempLocation[0] == '-') { + Daylight = 0xff; //make it invalid = will not use + } if (Daylight != 0 && Daylight != 1 && Daylight != 3) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellLevel2HiiHandle, L"-d"); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellLevel2HiiHandle, L"time", TempLocation, L"-d"); ShellStatus = SHELL_INVALID_PARAMETER; } } else { @@ -535,7 +614,7 @@ ShellCommandRunTime ( if (ShellStatus == SHELL_SUCCESS) { ShellStatus = CheckAndSetTime(ShellCommandLineGetRawValue(Package, 1), Tz, Daylight); if (ShellStatus != SHELL_SUCCESS) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, ShellCommandLineGetRawValue(Package, 1)); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"time", ShellCommandLineGetRawValue(Package, 1)); ShellStatus = SHELL_INVALID_PARAMETER; } } @@ -568,7 +647,7 @@ STATIC CONST SHELL_PARAM_ITEM TimeZoneParamList2[] = { STATIC CONST SHELL_PARAM_ITEM TimeZoneParamList3[] = { {L"-l", TypeFlag}, {L"-f", TypeFlag}, - {L"-s", TypeValue}, + {L"-s", TypeTimeValue}, {NULL, TypeMax} }; @@ -607,7 +686,8 @@ STATIC CONST SHELL_PARAM_ITEM TimeZoneParamList3[] = { {-660 , STRING_TOKEN (STR_TIMEZONE_P11)}, {-720 , STRING_TOKEN (STR_TIMEZONE_P12)}, {-780 , STRING_TOKEN (STR_TIMEZONE_P13)}, - {-840 , STRING_TOKEN (STR_TIMEZONE_P14)} + {-840 , STRING_TOKEN (STR_TIMEZONE_P14)}, + {EFI_UNSPECIFIED_TIMEZONE, STRING_TOKEN (STR_TIMEZONE_LOCAL)} }; /** @@ -637,12 +717,27 @@ CheckAndSetTimeZone ( return (SHELL_INVALID_PARAMETER); } + if (StrniCmp (TimeZoneString, L"_local", StrLen (TimeZoneString)) == NULL) { + Status = gRT->GetTime (&TheTime, NULL); + if (EFI_ERROR (Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"gRT->GetTime", Status); + return (SHELL_DEVICE_ERROR); + } + + TheTime.TimeZone = EFI_UNSPECIFIED_TIMEZONE; + Status = gRT->SetTime (&TheTime); + if (!EFI_ERROR(Status)){ + return (SHELL_SUCCESS); + } + return (SHELL_INVALID_PARAMETER); + } if (TimeZoneString != NULL && !InternalIsTimeLikeString(TimeZoneString, L':', 1, 1, TRUE)) { return (SHELL_INVALID_PARAMETER); } Status = gRT->GetTime(&TheTime, NULL); if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"timezone", L"gRT->GetTime", Status); return (SHELL_DEVICE_ERROR); } @@ -659,7 +754,7 @@ CheckAndSetTimeZone ( if (*Walker == L'-') { TheTime.TimeZone = (INT16)((ShellStrToUintn (++Walker)) * 60); } else { - TheTime.TimeZone = (INT16)((ShellStrToUintn (Walker)) * -60); + TheTime.TimeZone = (INT16)((INT16)(ShellStrToUintn (Walker)) * -60); } if (Walker2 != NULL) { Walker = Walker2 + 1; @@ -731,14 +826,14 @@ ShellCommandRunTimeZone ( // parse the command line // if (PcdGet8(PcdShellSupportLevel) == 2) { - Status = ShellCommandLineParse (TimeZoneParamList2, &Package, &ProblemParam, FALSE); + Status = ShellCommandLineParse (TimeZoneParamList2, &Package, &ProblemParam, TRUE); } else { ASSERT(PcdGet8(PcdShellSupportLevel) == 3); - Status = ShellCommandLineParseEx (TimeZoneParamList3, &Package, &ProblemParam, FALSE, TRUE); + Status = ShellCommandLineParseEx (TimeZoneParamList3, &Package, &ProblemParam, TRUE, TRUE); } if (EFI_ERROR(Status)) { if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, ProblemParam); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"timezone", ProblemParam); FreePool(ProblemParam); ShellStatus = SHELL_INVALID_PARAMETER; } else { @@ -749,18 +844,18 @@ ShellCommandRunTimeZone ( // check for "-?" // if (ShellCommandLineGetCount(Package) > 1) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"timezone"); ShellStatus = SHELL_INVALID_PARAMETER; } else if (ShellCommandLineGetFlag(Package, L"-?")) { ASSERT(FALSE); } else if (ShellCommandLineGetFlag(Package, L"-s")) { if ((ShellCommandLineGetFlag(Package, L"-l")) || (ShellCommandLineGetFlag(Package, L"-f"))) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"-l or -f"); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"timezone", L"-l or -f"); ShellStatus = SHELL_INVALID_PARAMETER; } else { ASSERT(PcdGet8(PcdShellSupportLevel) == 3); if (ShellCommandLineGetValue(Package, L"-s") == NULL) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellLevel2HiiHandle, L"-s"); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellLevel2HiiHandle, L"timezone", L"-s"); ShellStatus = SHELL_INVALID_PARAMETER; } else { // @@ -768,7 +863,7 @@ ShellCommandRunTimeZone ( // ShellStatus = CheckAndSetTimeZone(ShellCommandLineGetValue(Package, L"-s")); if (ShellStatus != SHELL_SUCCESS) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, ShellCommandLineGetValue(Package, L"-s")); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"timezone", ShellCommandLineGetValue(Package, L"-s")); ShellStatus = SHELL_INVALID_PARAMETER; } } @@ -788,7 +883,10 @@ ShellCommandRunTimeZone ( // Get Current Time Zone Info // Status = gRT->GetTime(&TheTime, NULL); - ASSERT_EFI_ERROR(Status); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"timezone", L"gRT->GetTime", Status); + return (SHELL_DEVICE_ERROR); + } if (TheTime.TimeZone != EFI_UNSPECIFIED_TIMEZONE) { Found = FALSE; @@ -806,11 +904,7 @@ ShellCommandRunTimeZone ( // // Print basic info only // - if (TheTime.TimeZone == EFI_UNSPECIFIED_TIMEZONE) { - TzMinutes = 0; - } else { - TzMinutes = (ABS(TheTime.TimeZone)) % 60; - } + TzMinutes = (ABS(TheTime.TimeZone)) % 60; ShellPrintHiiEx ( -1, @@ -818,8 +912,8 @@ ShellCommandRunTimeZone ( NULL, STRING_TOKEN(STR_TIMEZONE_SIMPLE), gShellLevel2HiiHandle, - TheTime.TimeZone==EFI_UNSPECIFIED_TIMEZONE?0:(TheTime.TimeZone > 0?L"-":L"+"), - TheTime.TimeZone==EFI_UNSPECIFIED_TIMEZONE?0:(ABS(TheTime.TimeZone)) / 60, + (TheTime.TimeZone > 0?L"-":L"+"), + (ABS(TheTime.TimeZone)) / 60, TzMinutes); } Found = TRUE; @@ -830,28 +924,45 @@ ShellCommandRunTimeZone ( // // Print basic info only // - if (TheTime.TimeZone == EFI_UNSPECIFIED_TIMEZONE) { - TzMinutes = 0; - } else { - TzMinutes = (ABS(TheTime.TimeZone)) % 60; - } + TzMinutes = (ABS(TheTime.TimeZone)) % 60; + ShellPrintHiiEx ( -1, -1, NULL, STRING_TOKEN(STR_TIMEZONE_SIMPLE), gShellLevel2HiiHandle, - TheTime.TimeZone==EFI_UNSPECIFIED_TIMEZONE?0:(TheTime.TimeZone > 0?L"-":L"+"), - TheTime.TimeZone==EFI_UNSPECIFIED_TIMEZONE?0:(ABS(TheTime.TimeZone)) / 60, + (TheTime.TimeZone > 0?L"-":L"+"), + (ABS(TheTime.TimeZone)) / 60, TzMinutes); + if (ShellCommandLineGetFlag(Package, L"-f")) { ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN(STR_TIMEZONE_NI), gShellLevel2HiiHandle); } } } else { // - // TimeZone was EFI_UNSPECIFIED_TIMEZONE (unknown) from GetTime() + // TimeZone was EFI_UNSPECIFIED_TIMEZONE (local) from GetTime() // + if (ShellCommandLineGetFlag (Package, L"-f")) { + for ( LoopVar = 0 + ; LoopVar < sizeof (TimeZoneList) / sizeof (TimeZoneList[0]) + ; LoopVar++ + ){ + if (TheTime.TimeZone == TimeZoneList[LoopVar].TimeZone) { + // + // Print all info about current time zone + // + ShellPrintHiiEx (-1, -1, NULL, TimeZoneList[LoopVar].StringId, gShellLevel2HiiHandle); + break; + } + } + } else { + // + // Print basic info only + // + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_TIMEZONE_SIMPLE_LOCAL), gShellLevel2HiiHandle); + } } } }