blob: b2414c7f0a5258d2d45dfea68572a879d311166e [file] [log] [blame]
Jeff Thompson9ae4d782013-10-17 10:25:54 -07001/**
2 * Copyright (C) 2013 Regents of the University of California.
3 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
4 * See COPYING for copyright and distribution information.
5 */
6
7#ifndef NDN_TIME_H
8#define NDN_TIME_H
9
Jeff Thompson9a8e82f2013-10-17 14:13:43 -070010#include <ndn-cpp/c/common.h>
11
Jeff Thompson9ae4d782013-10-17 10:25:54 -070012#ifdef __cplusplus
13extern "C" {
14#endif
15
16/**
17 * Use gettimeofday to return the current time in milliseconds.
18 * @return The current time in milliseconds since 1/1/1970, including fractions of a millisecond according to timeval.tv_usec.
19 */
Jeff Thompson9a8e82f2013-10-17 14:13:43 -070020ndn_MillisecondsSince1970
Jeff Thompson9ae4d782013-10-17 10:25:54 -070021ndn_getNowMilliseconds();
22
Jeff Thompson5a6ce832013-10-18 11:54:35 -070023/**
Jeff Thompsonfdaaa582013-10-18 13:05:10 -070024 * Convert the time from milliseconds to an ISO time string, for example "20131018T184138.423355".
Jeff Thompson5a6ce832013-10-18 11:54:35 -070025 * @param milliseconds The time in milliseconds since 1/1/1970, including fractions of a millisecond.
26 * @param isoString A buffer of at least 23 bytes to receive the null-terminated ISO time string.
27 */
28void
29ndn_toIsoString(ndn_MillisecondsSince1970 time, char *isoString);
30
Jeff Thompsonfdaaa582013-10-18 13:05:10 -070031/**
32 * Parse the ISO time string and return the time in milliseconds.
33 * @param isoString The ISO time string, for example "20131018T184138.423355".
34 * @return The time in milliseconds since 1/1/1970, including fractions of a millisecond.
35 */
36ndn_MillisecondsSince1970
37ndn_fromIsoString(const char* isoString);
38
Jeff Thompson9ae4d782013-10-17 10:25:54 -070039#ifdef __cplusplus
40}
41#endif
42
43#endif