<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Problem with &amp;quot;time&amp;quot; in C programming in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-quot-time-quot-in-c-programming/m-p/3554889#M639900</link>
    <description>Yes. Of course. You must include time.h lib.&lt;BR /&gt;pls refer my program as example&lt;BR /&gt;tienna</description>
    <pubDate>Tue, 31 May 2005 20:48:18 GMT</pubDate>
    <dc:creator>Nguyen Anh Tien</dc:creator>
    <dc:date>2005-05-31T20:48:18Z</dc:date>
    <item>
      <title>Problem with "time" in C programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-quot-time-quot-in-c-programming/m-p/3554885#M639896</link>
      <description>I see some syntax on a c program script which I dun quite understand...hope u guys can help..&lt;BR /&gt;Does this require "time.h"?&lt;BR /&gt;"&lt;BR /&gt;long now;&lt;BR /&gt;struct tm *c_time;&lt;BR /&gt;&lt;BR /&gt;now= time(0);&lt;BR /&gt;c_time= localtime(&amp;amp;now); "&lt;BR /&gt;&lt;BR /&gt;and what dictate the value of c_time and now?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance</description>
      <pubDate>Tue, 31 May 2005 08:41:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-quot-time-quot-in-c-programming/m-p/3554885#M639896</guid>
      <dc:creator>Henry Chua</dc:creator>
      <dc:date>2005-05-31T08:41:14Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with "time" in C programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-quot-time-quot-in-c-programming/m-p/3554886#M639897</link>
      <description># man 2 localtime&lt;BR /&gt;&lt;BR /&gt;c_time is now a pointer to a struct that contains the broken down elements of the local time&lt;BR /&gt;&lt;BR /&gt;     The &lt;TIME.H&gt; header file contains declarations of all relevant&lt;BR /&gt;      functions and externals.  It also contains the tm structure, which&lt;BR /&gt;      includes the following members:&lt;BR /&gt;&lt;BR /&gt;           int tm_sec;      /* seconds after the minute â   [0,61] */&lt;BR /&gt;           int tm_min;      /* minutes after the hour â   [0,59] */&lt;BR /&gt;           int tm_hour;     /* hours â   [0,23] */&lt;BR /&gt;           int tm_mday;     /* day of month â   [1,31] */&lt;BR /&gt;           int tm_mon;      /* month of year â   [0,11] */&lt;BR /&gt;           int tm_year;     /* years since 1900 */&lt;BR /&gt;           int tm_wday;     /* days since Sunday â   [0,6] */&lt;BR /&gt;           int tm_yday;     /* days since January 1 â   [0,365] */&lt;BR /&gt;           int tm_isdst;    /* daylight savings time flag */&lt;BR /&gt;&lt;BR /&gt;And strict ANSI wise that code isn't even good:&lt;BR /&gt;&lt;BR /&gt;--8&amp;lt;---&lt;BR /&gt;#incluse &lt;UNISTD.H&gt;&lt;BR /&gt;#include &lt;TIME.H&gt;&lt;BR /&gt;&lt;BR /&gt;:&lt;BR /&gt;:&lt;BR /&gt;&lt;BR /&gt;time_t now;&lt;BR /&gt;struct tm *c_time;&lt;BR /&gt;&lt;BR /&gt;now = time (0);&lt;BR /&gt;c_time= localtime (&amp;amp;now);&lt;BR /&gt;&lt;BR /&gt;(void)printf ("Now: %02d-%02d-%04d %02d:%02d:%02d\n", c_time-&amp;gt;tm_mday, c_time-&amp;gt;tm_mon + 1, c_time-&amp;gt;tm_year + 1900, c_time-&amp;gt;tm_hour, c_time-&amp;gt;tm_min, c_time-&amp;gt;tm_sec);&lt;BR /&gt;--&amp;gt;8---&lt;BR /&gt;&lt;BR /&gt;Enjo&lt;/TIME.H&gt;&lt;/UNISTD.H&gt;&lt;/TIME.H&gt;</description>
      <pubDate>Tue, 31 May 2005 08:49:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-quot-time-quot-in-c-programming/m-p/3554886#M639897</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2005-05-31T08:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with "time" in C programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-quot-time-quot-in-c-programming/m-p/3554887#M639898</link>
      <description>Yes you need #inclide &lt;TIME.H&gt; and I don't like your use of 0 in place of NULL.&lt;BR /&gt;&lt;BR /&gt;The time() function simply returns the number of seconds since 00:00:00 1-Jan-1970 UTC. If you send a NULL pointer to time the number of seconds is returned; if you send in a non-null pointer to time() the the value is stored in the variable pointed to.&lt;BR /&gt;&lt;BR /&gt;int main()&lt;BR /&gt;{&lt;BR /&gt;  timt_t now = 0;&lt;BR /&gt;  struct tm *t = NULL;&lt;BR /&gt;&lt;BR /&gt;  now = time((time_t *) NULL);&lt;BR /&gt;  t = localtime(&amp;amp;now);&lt;BR /&gt;  (void) printf("Year: %d\n",t-&amp;gt;tm_year + 1900);&lt;BR /&gt;  return(0);&lt;BR /&gt;} /* main */&lt;BR /&gt;&lt;/TIME.H&gt;</description>
      <pubDate>Tue, 31 May 2005 08:54:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-quot-time-quot-in-c-programming/m-p/3554887#M639898</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-05-31T08:54:00Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with "time" in C programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-quot-time-quot-in-c-programming/m-p/3554888#M639899</link>
      <description>Thanks for the info guys,&lt;BR /&gt;&lt;BR /&gt;Just another question.. if my time(); = 1117524722, how can i decode them into ,year,month,day,hour,min,sec?&lt;BR /&gt;&lt;BR /&gt;regards&lt;BR /&gt;Henry</description>
      <pubDate>Tue, 31 May 2005 20:29:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-quot-time-quot-in-c-programming/m-p/3554888#M639899</guid>
      <dc:creator>Henry Chua</dc:creator>
      <dc:date>2005-05-31T20:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with "time" in C programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-quot-time-quot-in-c-programming/m-p/3554889#M639900</link>
      <description>Yes. Of course. You must include time.h lib.&lt;BR /&gt;pls refer my program as example&lt;BR /&gt;tienna</description>
      <pubDate>Tue, 31 May 2005 20:48:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-quot-time-quot-in-c-programming/m-p/3554889#M639900</guid>
      <dc:creator>Nguyen Anh Tien</dc:creator>
      <dc:date>2005-05-31T20:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with "time" in C programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-quot-time-quot-in-c-programming/m-p/3554890#M639901</link>
      <description>You can use strftime(). You can print the date in the format of your choice. You will need to pass c_time as last argument to strftime().</description>
      <pubDate>Wed, 01 Jun 2005 00:22:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-quot-time-quot-in-c-programming/m-p/3554890#M639901</guid>
      <dc:creator>Amit Agarwal_1</dc:creator>
      <dc:date>2005-06-01T00:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with "time" in C programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-quot-time-quot-in-c-programming/m-p/3554891#M639902</link>
      <description>Henry, &lt;BR /&gt;&lt;BR /&gt;Just re-read procura's reply. It's all there.&lt;BR /&gt;&lt;BR /&gt;Now, instead of feeding now with time(), feed it your actual value!? (of course I would no longer call it 'now' but create a new time_t sometime; :-).&lt;BR /&gt;&lt;BR /&gt;In quick perl examples:&lt;BR /&gt;&lt;BR /&gt;# perl -e "print scalar localtime(1117524722)"&lt;BR /&gt;Tue May 31 03:32:02 2005&lt;BR /&gt;&lt;BR /&gt;# perl -e "print join (',',localtime(1117524722))"&lt;BR /&gt;2,32,3,31,4,105,2,150,1&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;hth,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 01 Jun 2005 00:29:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-quot-time-quot-in-c-programming/m-p/3554891#M639902</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-06-01T00:29:46Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with "time" in C programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-quot-time-quot-in-c-programming/m-p/3554892#M639903</link>
      <description>In addition, you can use mktime() to convert 1117524722 back to the year, month, etc.</description>
      <pubDate>Wed, 22 Jun 2005 13:16:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-quot-time-quot-in-c-programming/m-p/3554892#M639903</guid>
      <dc:creator>sw_5</dc:creator>
      <dc:date>2005-06-22T13:16:46Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with "time" in C programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-quot-time-quot-in-c-programming/m-p/3554893#M639904</link>
      <description>I have a question?  All the samples about localtime() everywhere never free the struct.  Could someone kindly let me know why?&lt;BR /&gt;&lt;BR /&gt;c_time= localtime(&amp;amp;now); &lt;BR /&gt;delete c_time;  // or use free for C</description>
      <pubDate>Wed, 22 Jun 2005 13:19:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-quot-time-quot-in-c-programming/m-p/3554893#M639904</guid>
      <dc:creator>sw_5</dc:creator>
      <dc:date>2005-06-22T13:19:58Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with "time" in C programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-quot-time-quot-in-c-programming/m-p/3554894#M639905</link>
      <description>Sorry, scrap the previous suggestion for using mktime().  That is for reverse-direction from year, mon -&amp;gt; time in seconds.</description>
      <pubDate>Wed, 22 Jun 2005 13:25:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-quot-time-quot-in-c-programming/m-p/3554894#M639905</guid>
      <dc:creator>sw_5</dc:creator>
      <dc:date>2005-06-22T13:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with "time" in C programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-quot-time-quot-in-c-programming/m-p/3554895#M639906</link>
      <description>localtime() would never free the data structure. If localtime() is supplied a NULL pointer then it returns the address of a static variable that is reused upon each invocation of the function. In that case, it is imperitive to copy the values to other variable before calling localtime again. If a non-NULL pointer is supplied then localtime stores the value there and it is the responsibility of the calling program to then free any dynamically allowcated memory.</description>
      <pubDate>Wed, 22 Jun 2005 13:44:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-quot-time-quot-in-c-programming/m-p/3554895#M639906</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-06-22T13:44:07Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with "time" in C programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-quot-time-quot-in-c-programming/m-p/5425861#M639907</link>
      <description>&lt;P&gt;&amp;gt;if you send in a non-null pointer to time()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You shouldn't do this because it causes the kernel to sweat.&amp;nbsp; Just use the return result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt;If localtime() is supplied a NULL pointer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;localtime(3) would probably abort on a NULL.&amp;nbsp; Are you thinking of localtime_r?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt;If a non-NULL pointer is supplied then localtime(3)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The input parm is of time_t*.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Dec 2011 12:48:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-quot-time-quot-in-c-programming/m-p/5425861#M639907</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-12-22T12:48:25Z</dc:date>
    </item>
  </channel>
</rss>

