mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-04 18:28:30 +00:00
Refactor gettimeofday()
This commit is contained in:
parent
4238e4def9
commit
af3df0893b
11 changed files with 195 additions and 36 deletions
29
examples/gettimeofday.c
Normal file
29
examples/gettimeofday.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
#if 0
|
||||
/*─────────────────────────────────────────────────────────────────╗
|
||||
│ To the extent possible under law, Justine Tunney has waived │
|
||||
│ all copyright and related or neighboring rights to this file, │
|
||||
│ as it is written in the following disclaimers: │
|
||||
│ • http://unlicense.org/ │
|
||||
│ • http://creativecommons.org/publicdomain/zero/1.0/ │
|
||||
╚─────────────────────────────────────────────────────────────────*/
|
||||
#endif
|
||||
#include "libc/assert.h"
|
||||
#include "libc/calls/struct/timeval.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/time/struct/tm.h"
|
||||
#include "libc/time/time.h"
|
||||
#include "net/http/http.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int rc;
|
||||
int64_t t;
|
||||
char p[30];
|
||||
struct tm tm;
|
||||
struct timeval tv;
|
||||
rc = gettimeofday(&tv, 0);
|
||||
assert(!rc);
|
||||
t = tv.tv_sec;
|
||||
gmtime_r(&t, &tm);
|
||||
FormatHttpDateTime(p, &tm);
|
||||
printf("%s\n", p);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue