home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!pipex!warwick!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: <1992Dec22.185309.15061@gssec.bt.co.uk>
- Date: 22 Dec 92 18:53:09 GMT
- References: <BzDJuA.AGF@sdf.lonestar.org> <BzH0Bs.K4J@news.cecer.army.mil> <1992Dec21.172542.28171@linus.mitre.org>
- Sender: usenet@gssec.bt.co.uk
- Organization: BT, Software Engineering Centre, Glasgow, UK
- Lines: 62
-
- In article <1992Dec21.172542.28171@linus.mitre.org>,i
- jrv@mbunix.mitre.org (Van Zandt) writes:
- |>
- |> >>I have been working with some of the time functions (on a Sun
- |> >>SPARCstation IPX). After I make a call to strptime (to fill
- |> >>in the tm structure) I display the structure (with dbxtool) and
- |> >>find that the structure is filled in incorrectly. What am I
- |> >>doing wrong?
- |> ...
- |> >> struct tm *my_tm;
- |> >>
- |> >> (void)strptime(timeString,"%Y,%j/%H%M%S",my_tm);
- |>
- |> my_tm needs to be initialized to point to a struct tm before
- |> asking strptime to fill it in.
- |>
- |> - Jim Van Zandt <jrv@mitre.org>
-
- I had problems with strptime on the Sun a few months ago and
- came to the conclusion that it was broken. Are you saying that
- the following should work?
-
- #include <sys/types.h>
- #include <sys/time.h>
- #include <time.h>
- #include <ctype.h>
- #include <stdio.h>
-
- main()
- {
- static char *s = "19920901111500";
- struct tm *tm;
- time_t tloc;
-
- time(&tloc);
- tm = localtime(&tloc);
- strptime(s, "%Y%m%d%H%M%S", tm);
- tloc = timelocal(tm);
-
- printf("Converted %s to %s, tloc = %ld\n",
- s, ctime(&tloc), tloc);
- }
-
- I have also tried:
-
- int main()
- {
- static char *s = "19920901111500";
- struct tm tm;
- time_t tloc;
-
- strptime(s, "%Y%m%d%H%M%S", &tm);
- tloc = timelocal(&tm);
- ...
-
- No matter how I twist things it always fails.
-
- -- Alan.
- --------------------------------------------
- awright@gssec.bt.co.uk (Alan Wright)
- BT, Software Engineering Centre, Glasgow, UK
- --------------------------------------------
-