diff options
author | Konstantin Aladyshev <aladyshev22@gmail.com> | 2022-03-21 17:59:51 +0300 |
---|---|---|
committer | Konstantin Aladyshev <aladyshev22@gmail.com> | 2022-03-21 18:05:07 +0300 |
commit | e6a90b38c0f25d94d9a874f20fbb63d3151da033 (patch) | |
tree | a35856a6ea2e587bb9bdc3f86228dcfad41c4396 /Lessons/Lesson_67/README.md | |
parent | c28cd7e7867f856318c121a15f73f2b499dd2bb9 (diff) | |
download | UEFI-Lessons-e6a90b38c0f25d94d9a874f20fbb63d3151da033.tar.gz UEFI-Lessons-e6a90b38c0f25d94d9a874f20fbb63d3151da033.tar.bz2 UEFI-Lessons-e6a90b38c0f25d94d9a874f20fbb63d3151da033.zip |
Add lesson 67
Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Diffstat (limited to 'Lessons/Lesson_67/README.md')
-rw-r--r-- | Lessons/Lesson_67/README.md | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/Lessons/Lesson_67/README.md b/Lessons/Lesson_67/README.md new file mode 100644 index 0000000..5ad10a6 --- /dev/null +++ b/Lessons/Lesson_67/README.md @@ -0,0 +1,85 @@ +# `date` element + +`date` input element is used to store date (https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/211_vfr_form_definition#2.11.6.9-vfr-date-statement-definition) + +Add this code to `UefiLessonsPkg/HIIFormDataElements/Form.vfr`: +``` +date + varid = FormData.DateValue, + prompt = STRING_TOKEN(DATE_PROMPT), + help = STRING_TOKEN(DATE_HELP), +enddate; +``` + +Add strings to `UefiLessonsPkg/HIIFormDataElements/Strings.uni` +``` +#string DATE_PROMPT #language en-US "Date prompt" +#string DATE_HELP #language en-US "Date help" +``` + +Date is encoded in special `EFI_HII_DATE` type (https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Uefi/UefiInternalFormRepresentation.h): +``` +typedef struct { + UINT16 Year; + UINT8 Month; + UINT8 Day; +} EFI_HII_DATE; +``` + +Therefore add it to our structure in `UefiLessonsPkg/HIIFormDataElements/Data.h`: +``` +typedef struct { + ... + EFI_HII_DATE DateValue; +} UEFI_VARIABLE_STRUCTURE; +``` + +This will result to this element: + +![Date1](Date1.png?raw=true "Date1") + +The value is displayed in `MM/DD/YYYY` format. So it is possible to store `02/20/2022`, but not `20/02/2022`. + +As for checks, even the leap year is checked. You can enter `02/29/2020`, but not `02/29/2021`. + +# `time` element + +`time` VFR input element is used to store time (https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/211_vfr_form_definition#2.11.6.10-vfr-time-statement-definition) + +Add this code to `UefiLessonsPkg/HIIFormDataElements/Form.vfr`: +``` +time + varid = FormData.TimeValue, + prompt = STRING_TOKEN(TIME_PROMPT), + help = STRING_TOKEN(TIME_HELP), +endtime; +``` + +Add strings to `UefiLessonsPkg/HIIFormDataElements/Strings.uni` +``` +#string TIME_PROMPT #language en-US "Time prompt" +#string TIME_HELP #language en-US "Time help" +``` + +Time is encoded in special `EFI_HII_TIME` type (https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Uefi/UefiInternalFormRepresentation.h): +``` +typedef struct { + UINT8 Hour; + UINT8 Minute; + UINT8 Second; +} EFI_HII_TIME; +``` + +Therefore add it to our structure in `UefiLessonsPkg/HIIFormDataElements/Data.h`: +``` +typedef struct { + ... + EFI_HII_TIME TimeValue; +} UEFI_VARIABLE_STRUCTURE; +``` + +This will result to this element: + +![Time1](Time1.png?raw=true "Time1") + +As with `date` element HII Form Browser doesn't allow to set invalid time values. |