summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>2011-07-28 02:14:29 +0000
committerydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>2011-07-28 02:14:29 +0000
commit38d6bb9e713972c33e7c9e57b85ce10a71b32091 (patch)
tree8ba89dac7f9d2820fcac29a3a5b4abeecc67cfa9 /MdeModulePkg
parent550486ed3be702a9bd759fedd4e23e4d89c58432 (diff)
downloadedk2-38d6bb9e713972c33e7c9e57b85ce10a71b32091.tar.gz
edk2-38d6bb9e713972c33e7c9e57b85ce10a71b32091.tar.bz2
edk2-38d6bb9e713972c33e7c9e57b85ce10a71b32091.zip
Adjust the day field when update the month and year field.
Signed-off-by:ydong10 Reviewed-by:lgao4 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12054 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/InputHandler.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/InputHandler.c b/MdeModulePkg/Universal/SetupBrowserDxe/InputHandler.c
index 8f3b9e72dc..ecaf1d7429 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/InputHandler.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/InputHandler.c
@@ -214,6 +214,70 @@ ReadString (
}
+/**
+ Adjust the value to the correct one. Rules follow the sample:
+ like: Year change: 2012.02.29 -> 2013.02.29 -> 2013.02.01
+ Month change: 2013.03.29 -> 2013.02.29 -> 2013.02.28
+
+ @param Question Pointer to current question.
+ @param Sequence The sequence of the field in the question.
+**/
+VOID
+AdjustQuestionValue (
+ IN FORM_BROWSER_STATEMENT *Question,
+ IN UINT8 Sequence
+ )
+{
+ UINT8 Month;
+ UINT16 Year;
+ UINT8 Maximum;
+ UINT8 Minimum;
+
+ if (Question->Operand != EFI_IFR_DATE_OP) {
+ return;
+ }
+
+ Month = Question->HiiValue.Value.date.Month;
+ Year = Question->HiiValue.Value.date.Year;
+ Minimum = 1;
+
+ switch (Month) {
+ case 2:
+ if ((Year % 4) == 0 && ((Year % 100) != 0 || (Year % 400) == 0)) {
+ Maximum = 29;
+ } else {
+ Maximum = 28;
+ }
+ break;
+ case 4:
+ case 6:
+ case 9:
+ case 11:
+ Maximum = 30;
+ break;
+ default:
+ Maximum = 31;
+ break;
+ }
+
+ //
+ // Change the month area.
+ //
+ if (Sequence == 0) {
+ if (Question->HiiValue.Value.date.Day > Maximum) {
+ Question->HiiValue.Value.date.Day = Maximum;
+ }
+ }
+
+ //
+ // Change the Year area.
+ //
+ if (Sequence == 2) {
+ if (Question->HiiValue.Value.date.Day > Maximum) {
+ Question->HiiValue.Value.date.Day = Minimum;
+ }
+ }
+}
/**
This routine reads a numeric value from the user input.
@@ -647,6 +711,16 @@ EnterCarriageReturn:
}
//
+ // Adjust the value to the correct one.
+ // Sample like: 2012.02.29 -> 2013.02.29 -> 2013.02.01
+ // 2013.03.29 -> 2013.02.29 -> 2013.02.28
+ //
+ if (Question->Operand == EFI_IFR_DATE_OP &&
+ (MenuOption->Sequence == 0 || MenuOption->Sequence == 2)) {
+ AdjustQuestionValue (Question, (UINT8)MenuOption->Sequence);
+ }
+
+ //
// Check to see if the Value is something reasonable against consistency limitations.
// If not, let's kick the error specified.
//