irods  4.2.8
About: iRODS (the integrated Rule Oriented Data System) is a distributed data-management system for creating data grids, digital libraries, persistent archives, and real-time data systems.
  Fossies Dox: irods-4.2.8.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

datetime.cpp
Go to the documentation of this file.
1 /* For copyright information please refer to files in the COPYRIGHT directory
2  */
3 
4 #include "datetime.hpp"
5 static char* defaultformat = "%b %d %Y %H:%M:%S";
6 /*
7  * returns 0 if failed
8  * 1 if succeeded
9  */
10 int strttime( char* timestr, char* timeformat, rodsLong_t* t ) {
11  if ( *timeformat == 0 ) {
12  timeformat = defaultformat;
13  }
14  struct tm tm;
15  memset(&tm, 0, sizeof(struct tm));
16  if ( strptime( timestr, timeformat, &tm ) == 0 ) {
17  return 0;
18  }
19  /* printf("year: %d; month: %d; day: %d;\n",
20  tm.tm_year, tm.tm_mon, tm.tm_mday);
21  printf("hour: %d; minute: %d; second: %d\n",
22  tm.tm_hour, tm.tm_min, tm.tm_sec);
23  printf("week day: %d; year day: %d\n", tm.tm_wday, tm.tm_yday);*/
24  tm.tm_isdst = -1;
25  *t = ( rodsLong_t ) mktime( &tm );
26  if ( *t == -1 ) {
27  return 0;
28  }
29  /*printf("seconds since the Epoch: %ld\n", (long) t); */
30  return 1;
31 }
32 
33 /*
34  * returns 0 if failed
35  * 1 if succeeded
36  */
37 int ttimestr( char* timestr, int n, char* timeformat, rodsLong_t* t ) {
38  if ( *timeformat == 0 ) {
39  timeformat = defaultformat;
40  }
41  time_t t2 = ( time_t ) * t;
42  struct tm tm = *localtime( &t2 );
43  if ( strftime( timestr, n, timeformat, &tm ) == 0 ) {
44  return 0;
45  }
46  return 1;
47 }
48 
ttimestr
int ttimestr(char *timestr, int n, char *timeformat, rodsLong_t *t)
Definition: datetime.cpp:37
defaultformat
static char * defaultformat
Definition: datetime.cpp:5
datetime.hpp
strttime
int strttime(char *timestr, char *timeformat, rodsLong_t *t)
Definition: datetime.cpp:10
rodsLong_t
long long rodsLong_t
Definition: rodsType.h:32