home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / c / 19035 < prev    next >
Encoding:
Internet Message Format  |  1992-12-30  |  1.4 KB

  1. Path: sparky!uunet!pipex!bnr.co.uk!uknet!axion!gssec.bt.co.uk!awright
  2. From: awright@gssec.bt.co.uk (Alan Wright)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Need HELP with strptime....any answers/clues?????
  5. Message-ID: <1992Dec30.163058.17357@gssec.bt.co.uk>
  6. Date: 30 Dec 92 16:30:58 GMT
  7. Sender: usenet@gssec.bt.co.uk
  8. Organization: BT, Software Engineering Centre, Glasgow, UK
  9. Lines: 30
  10.  
  11. Thank you to everyone who replied to my posting regarding the
  12. broken-ness of strptime. I had something like:
  13.  
  14.    buf = "19921230033515"
  15.    strptime(buf, "%Y%m%d%H%M%S", tm);
  16.  
  17. The problem is that strptime parses this string (buf) as one number
  18. which is too large, rather than lots of two- and four-digit numbers.
  19. What I needed were a few delimiters - like spaces. My excuse is that
  20. this never occured to me because I was also using strftime and in
  21. this case it is perfectly okay not to use spaces, i.e.
  22.  
  23.    strftime(buf, DATE_SZ, "%Y%m%d%H%M%S", tm);
  24.  
  25. I was simply looking for a converse operation. The manual page does
  26. not specify how the format string should be parsed. My fault for not
  27. thinking clearly. Okay so it's not a good excuse.
  28.  
  29. The following works:
  30.  
  31.    buf = "1992 12 30 03 35 15";
  32.    strptime(buf, "%Y %m %d %H %M %S", tm);
  33.  
  34. Thanks,
  35.  
  36. -- Alan
  37. --------------------------------------------
  38. awright@gssec.bt.co.uk (Alan Wright)
  39. BT, Software Engineering Centre, Glasgow, UK
  40. --------------------------------------------
  41.