FreeBASIC
0.91.0
Main Page
Data Structures
Files
File List
Globals
time_date.c
Go to the documentation of this file.
1
/* date$ function */
2
3
#include "
fb.h
"
4
#include <time.h>
5
6
/*:::::*/
7
FBCALL
FBSTRING
*
fb_Date
(
void
)
8
{
9
FBSTRING
*dst;
10
time_t rawtime;
11
struct
tm *ptm;
12
13
/* guard by global lock because time/localtime might not be thread-safe */
14
FB_LOCK
();
15
16
rawtime = time(
NULL
);
17
18
/* Note: localtime() can return NULL due to weird value from time() */
19
if
( ((ptm = localtime( &rawtime )) !=
NULL
) &&
20
((dst =
fb_hStrAllocTemp
(
NULL
, 2+1+2+1+4 )) !=
NULL
)
/* done last so it's not leaked */
) {
21
sprintf( dst->
data
,
"%02d-%02d-%04d"
, 1+ptm->tm_mon, ptm->tm_mday, 1900+ptm->tm_year );
22
}
else
{
23
dst = &
__fb_ctx
.
null_desc
;
24
}
25
26
FB_UNLOCK
();
27
28
return
dst;
29
}
rtlib
time_date.c
Generated on Thu Jan 23 2014 19:40:14 for FreeBASIC by
1.8.4