Changeset ad2718d in mainline


Ignore:
Timestamp:
2012-04-18T23:12:57Z (12 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
86e81a9
Parents:
0885f7e
Message:

date: improve comments and bad parameter format detection

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/date/date.c

    r0885f7e rad2718d  
    194194}
    195195
     196/** Read the day, month and year from a string
     197 *  with the following format: DD/MM/YYYY
     198 */
    196199static int
    197200read_date_from_arg(char *wdate, struct tm *t)
     
    199202        int rc;
    200203
    201         if (str_size(wdate) != 10) /* DD/MM/YYYY */
     204        if (str_size(wdate) != 10) /* str_size("DD/MM/YYYY") == 10 */
    202205                return EINVAL;
    203206
     
    221224}
    222225
     226/** Read the hours, minutes and seconds from a string
     227 *  with the following format: HH:MM:SS or HH:MM
     228 */
    223229static int
    224230read_time_from_arg(char *wtime, struct tm *t)
     
    226232        int rc;
    227233        size_t len = str_size(wtime);
    228         bool sec_present = len > 5;
    229 
    230         if (len > 8 || len < 5) /* HH:MM[:SS] */
     234        bool sec_present = len == 8;
     235
     236        /* str_size("HH:MM") == 5 */
     237        /* str_size("HH:MM:SS") == 8 */
     238        if (len != 8 && len != 5)
    231239                return EINVAL;
    232240
Note: See TracChangeset for help on using the changeset viewer.