blob: 674ef213268b2f85a8ffc259357920cde27abb97 [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
Yingdi Yu61ec2722014-01-20 14:22:32 -080010#include <ndn-cpp-dev/c/common.h>
Jeff Thompsonea946202013-10-18 14:35:32 -070011#include "../errors.h"
Jeff Thompson9a8e82f2013-10-17 14:13:43 -070012
Jeff Thompson9ae4d782013-10-17 10:25:54 -070013#ifdef __cplusplus
14extern "C" {
15#endif
16
17/**
18 * Use gettimeofday to return the current time in milliseconds.
19 * @return The current time in milliseconds since 1/1/1970, including fractions of a millisecond according to timeval.tv_usec.
20 */
Jeff Thompson9a8e82f2013-10-17 14:13:43 -070021ndn_MillisecondsSince1970
Jeff Thompson9ae4d782013-10-17 10:25:54 -070022ndn_getNowMilliseconds();
23
Jeff Thompson5a6ce832013-10-18 11:54:35 -070024/**
Jeff Thompsonfdaaa582013-10-18 13:05:10 -070025 * Convert the time from milliseconds to an ISO time string, for example "20131018T184138.423355".
Jeff Thompson5a6ce832013-10-18 11:54:35 -070026 * @param milliseconds The time in milliseconds since 1/1/1970, including fractions of a millisecond.
27 * @param isoString A buffer of at least 23 bytes to receive the null-terminated ISO time string.
Jeff Thompsonea946202013-10-18 14:35:32 -070028 * @return 0 for success, else an error code including if we don't have necessary standard library support.
Jeff Thompson5a6ce832013-10-18 11:54:35 -070029 */
Jeff Thompsonea946202013-10-18 14:35:32 -070030ndn_Error
31ndn_toIsoString(ndn_MillisecondsSince1970 milliseconds, char *isoString);
Jeff Thompson5a6ce832013-10-18 11:54:35 -070032
Jeff Thompsonfdaaa582013-10-18 13:05:10 -070033/**
34 * Parse the ISO time string and return the time in milliseconds.
35 * @param isoString The ISO time string, for example "20131018T184138.423355".
Jeff Thompsonea946202013-10-18 14:35:32 -070036 * @param milliseconds Return the time in milliseconds since 1/1/1970, including fractions of a millisecond.
37 * @return 0 for success, else an error code including if we don't have necessary standard library support.
Jeff Thompsonfdaaa582013-10-18 13:05:10 -070038 */
Jeff Thompsonea946202013-10-18 14:35:32 -070039ndn_Error
40ndn_fromIsoString(const char* isoString, ndn_MillisecondsSince1970 *milliseconds);
Jeff Thompsonfdaaa582013-10-18 13:05:10 -070041
Jeff Thompson9ae4d782013-10-17 10:25:54 -070042#ifdef __cplusplus
43}
44#endif
45
46#endif