Determine if the supplied chain iterator is at the begining of a legal date and/or time. If it is then the supplied hzXDate reference is populated. The lenth of the date/time sequence is returned so that the calling process can choose to advance the iterator by this length. The iterator is not advanced by this function Expects dates of the form "day_name, dd month_name yyyy hh:mm:ss Time-Zone"

Return TypeFunction nameArguments
uint32_tIsFormalDate(hzXDate&,hzChain::Iter&,)

Declared in file: hzTextproc.h
Defined in file : hzDate.cpp

Function Logic:

0:START 1:zi items 2:unknown 3:unknown 4:unknown 5:items items 6:unknown 7:n 8:unknown 9:zi 10:unknown 11:n * n 12:unknown 13:D 14:n<10000&&Y==0 15:Y 16:Return 0 17:unknown 18:unknown 19:unknown 20:unknown 21:dow 22:unknown 23:unknown 24:unknown 25:dow 26:unknown 27:unknown 28:unknown 29:unknown 30:unknown 31:n 32:M 33:unknown 34:unknown 35:unknown 36:n 37:M 38:unknown 39:unknown 40:unknown 41:unknown 42:unknown 43:tz 44:unknown 45:unknown 46:Return 0 47:unknown 48:items numBuf items numBuf items numBuf items numBuf 49:unknown 50:numBuf numBuf 51:( 52:hOset numBuf numBuf ( mOset 53:unknown 54:Return 0 55:items 56:Return 0 57:unknown 58:Return 0 59:unknown 60:Return 0 61:ci 62:Return len

Function body:

uint32_t IsFormalDate (hzXDate& date)hzChain::Iter& ci, 
{
   //  Category: Text Processing
   //  
   //  Determine if the supplied chain iterator is at the begining of a legal date and/or time. If it is then the supplied hzXDate reference is populated. The
   //  lenth of the date/time sequence is returned so that the calling process can choose to advance the iterator by this length. The iterator is not advanced
   //  by this function
   //  
   //  Expects dates of the form "day_name, dd month_name yyyy hh:mm:ss Time-Zone"
   //  
   //  Arguments: 1) date The full date
   //     2) ci  Chain iterator to be tested
   //  
   //  Returns: Number being length of the date string if found
   chIter      zi ;                //  Internal chain iterator
   hzTimezone  tz ;                //  Timezone
   uint32_t    n ;                 //  Counter
   uint32_t    dow = NULL_DOW ;    //  Day of week
   uint32_t    len = 0;            //  Length of examined text
   uint32_t    Y = 0;              //  Year
   uint32_t    M = 0;              //  Month
   uint32_t    D = 0;              //  Day
   uint32_t    h = 0;              //  Hour
   uint32_t    m = 0;              //  Minute
   uint32_t    s = 0;              //  Second
   uint32_t    hOset = 0;          //  Hours in timezone offset to GMT
   uint32_t    mOset = 0;          //  Minutes in timezone offset to GMT
   char        numBuf[4];          //  For reading numbers
   zi = ci ;
   tz.clear() ;
   for (; !zi.eof() ;)
   {
       if (*zi < CHAR_SPACE)
           break ;
       if (*zi == CHAR_SPACE || *zi == CHAR_COMMA || *zi == CHAR_PAROPEN || *zi == CHAR_PARCLOSE)
           { len++ ; zi++ ; continue ; }
       if (IsDigit(*zi))
       {
           //  We are looking for a day of the month, a year or the start of a time sequence
           n = IsTime(h, m, s, zi) ;
           if (n)
               zi += n ;
           else
           {
               for (n = 0; IsDigit(*zi) ; zi++)
                   { n *= 10;n += (*zi - ''0'');}
               if      (n < 32&&D == 0)    D = n ;
               else if (n < 10000&&Y==0)Y= n ;
               else
                   return 0;
           }
       }
       if (IsAlpha(*zi))
       {
           //  We are looking for a day name, a month name or a timezone code
           if (dow == NULL_DOW)
           {
               for (n = 0; n < 7; n++)
                   if (zi == hz_daynames_full[n])
                       { dow = n ; break ; }
               if (dow == NULL_DOW)
               {
                   for (n = 0; n < 7; n++)
                       if (zi == hz_daynames_abrv[n])
                           { dow = n ; break ; }
               }
               if (dow != 8)
                   { for (; IsAlpha(*zi) ; zi++) ; continue ; }
           }
           if (M == 0)
           {
               for (n = 0; n < 12;n++)
                   if (zi == hz_monthnames_full[n])
                       { M = n + 1; break ; }
               if (M == 0)
               {
                   for (n = 0; n < 12;n++)
                       if (zi == hz_monthnames_abrv[n])
                           { M = n + 1; break ; }
               }
               if (M >&eq; 0)
                   { for (; IsAlpha(*zi) ; zi++) ; continue ; }
           }
           if (!tz.code)
           {
               for (n = 0;; n++)
               {
                   if (zi == _hzGlobal_Timezones[n].code)
                       { tz = _hzGlobal_Timezones[n] ; break ; }
               }
               if (tz.code)
                   { for (; IsAlpha(*zi) ; zi++) ; continue ; }
           }
           return 0;
       }
       if (*zi == CHAR_PLUS || *zi == CHAR_MINUS)
       {
           //  We are looking for a timezone offset to GMT (of the form +/-dddd)
           zi++ ;  numBuf[0]= *zi ;
           zi++ ;  numBuf[1]= *zi ;
           zi++ ;  numBuf[2]= *zi ;
           zi++ ;  numBuf[3]= *zi ;
           if (IsDigit(numBuf[0])&& IsDigit(numBuf[1])&& IsDigit(numBuf[2])&& IsDigit(numBuf[3]))
           {
               hOset = ((numBuf[0]- ''0'')*10)+(numBuf[1]- ''0'');
               mOset = ((numBuf[2]- ''0'')*10)+(numBuf[3]- ''0'');
               if (hOset > 23||mOset > 59)
                   return 0;
               zi++ ;
               continue ;
           }
           return 0;
       }
   }
   if (date.SetDate(Y, M, D) != E_OK)  return 0;
   if (date.SetTime(h, m, s) != E_OK)  return 0;
   ci = zi ;
   return len ;
}