home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!pipex!bnr.co.uk!uknet!axion!gssec.bt.co.uk!awright
- From: awright@gssec.bt.co.uk (Alan Wright)
- Newsgroups: comp.lang.c
- Subject: Re: Need HELP with strptime....any answers/clues?????
- Message-ID: <1992Dec30.163058.17357@gssec.bt.co.uk>
- Date: 30 Dec 92 16:30:58 GMT
- Sender: usenet@gssec.bt.co.uk
- Organization: BT, Software Engineering Centre, Glasgow, UK
- Lines: 30
-
- Thank you to everyone who replied to my posting regarding the
- broken-ness of strptime. I had something like:
-
- buf = "19921230033515"
- strptime(buf, "%Y%m%d%H%M%S", tm);
-
- The problem is that strptime parses this string (buf) as one number
- which is too large, rather than lots of two- and four-digit numbers.
- What I needed were a few delimiters - like spaces. My excuse is that
- this never occured to me because I was also using strftime and in
- this case it is perfectly okay not to use spaces, i.e.
-
- strftime(buf, DATE_SZ, "%Y%m%d%H%M%S", tm);
-
- I was simply looking for a converse operation. The manual page does
- not specify how the format string should be parsed. My fault for not
- thinking clearly. Okay so it's not a good excuse.
-
- The following works:
-
- buf = "1992 12 30 03 35 15";
- strptime(buf, "%Y %m %d %H %M %S", tm);
-
- Thanks,
-
- -- Alan
- --------------------------------------------
- awright@gssec.bt.co.uk (Alan Wright)
- BT, Software Engineering Centre, Glasgow, UK
- --------------------------------------------
-