What if … Date/Time is too fuzzy for date/time parser?

Just recently I came across unusual (for HL7) Date/Time timestamp.

Example: 08/03 2011 11:54

i.e. dd/mm YYYY HH:MM

Here is simple way to handle it:

We use two extensions to string library – zfill() and tokenize(), both added to shared stringutil Module.

Last but not least – the code snippet 🙂

function string.tokenize(self)
   t  = {}
   for w in string.gmatch(self, "(%w+)" ) do
      t[#t+1] = w
   end
   return t
end

function string.zfill(self,n)
   local R = n
   local L = #self
   if L < R then 
      self = '0'..self
      self:zfill(R)
   else
      z = self   
   end

   return z
end

Leave A Comment?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.