]>
git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSPosix/posix_utilities.c
5 // Copyright (c) 2019 Apple Inc. All rights reserved.
8 #include "posix_utilities.h"
9 #include "mDNSEmbeddedAPI.h"
10 #include <stdlib.h> // for NULL
11 #include <stdio.h> // for snprintf
13 #include <sys/time.h> // for gettimeofday
15 mDNSexport
void getLocalTimestamp(char * const buffer
, mDNSu32 buffer_len
)
19 char date_time_str
[32];
20 char time_zone_str
[32];
22 gettimeofday(&now
, NULL
);
23 localtime_r(&now
.tv_sec
, &local_time
);
25 strftime(date_time_str
, sizeof(date_time_str
), "%F %T", &local_time
);
26 strftime(time_zone_str
, sizeof(time_zone_str
), "%z", &local_time
);
27 snprintf(buffer
, buffer_len
, "%s.%06lu%s", date_time_str
, (unsigned long)now
.tv_usec
, time_zone_str
);