Fixed driver license dates that might be missing (thanks, Patrick!).
authorRyan C. Gordon <icculus@icculus.org>
Mon, 23 Feb 2015 10:44:38 -0500
changeset 42 ca071626bfa0
parent 41 5155ff0e6d3d
child 43 85b1cb11d948
Fixed driver license dates that might be missing (thanks, Patrick!).

Some regions don't have expiring drivers licenses and don't use this field,
or maybe might only use some parts (year, month, day). Made this more robust.
1pass.lua
--- a/1pass.lua	Thu Dec 04 16:01:25 2014 -0500
+++ b/1pass.lua	Mon Feb 23 10:44:38 2015 -0500
@@ -204,9 +204,30 @@
 
 
 local function build_secret_menuitem_driverslic(menu, info, secure)
-    -- !!! FIXME: there's more data than this in a generic dictionary.
-    local birthdate = secure.birthdate_yy .. "/" .. string.sub("00" .. secure.birthdate_mm, -2) .. "/" .. string.sub("00" .. secure.birthdate_dd, -2)
+    -- !!! FIXME: there's more data for this menuitem than this, in a generic dictionary.
+
+    local birthdate = nil
+    if secure.birthdate_yy ~= nil then
+        birthdate = secure.birthdate_yy
+        if secure.birthdate_mm ~= nil then
+            birthdate = birthdate .. "/" .. string.sub("00" .. secure.birthdate_mm, -2)
+            if secure.birthdate_dd ~= nil then
+                birthdate = birthdate .. "/" .. string.sub("00" .. secure.birthdate_dd, -2)
+            end
+        end
+    end
+
     local expiredate = secure.expiry_date_yy .. "/" .. string.sub("00" .. secure.expiry_date_mm, -2)
+    if secure.expiry_date_yy ~= nil then
+        expiredate = secure.expiry_date_yy
+        if secure.expiry_date_mm ~= nil then
+            expiredate = expiredate .. "/" .. string.sub("00" .. secure.expiry_date_mm, -2)
+            if secure.expiry_date_dd ~= nil then
+                expiredate = expiredate .. "/" .. string.sub("00" .. secure.expiry_date_dd, -2)
+            end
+        end
+    end
+
     build_secret_menuitem(menu, "License number", secure.number)
     build_secret_menuitem(menu, "Class", secure.class)
     build_secret_menuitem(menu, "Expires", expiredate)