File:  [ELWIX - Embedded LightWeight unIX -] / libelwix / example / test_time.c
Revision 1.3: download - view: text, annotated - select for diffs - revision graph
Mon Apr 15 10:42:26 2024 UTC (7 months, 1 week ago) by misho
Branches: MAIN
CVS tags: elwix6_6, elwix6_5, elwix6_4, elwix6_3, elwix6_2, elwix6_1, elwix5_12, HEAD, ELWIX6_5, ELWIX6_4, ELWIX6_2, ELWIX6_1, ELWIX6_0, ELWIX5_11
Version 5.11

#include <stdio.h>
#include <string.h>
#include <time.h>
#include <elwix.h>


int
main(int argc, char **argv)
{
	time_t tim;
	struct tm *tm;
	char str[BUFSIZ];

	if (argc < 2)
		return 1;

	memset(str, 0, sizeof str);

	tim = time_Parse(argv[1]);
	printf("time_t=%lu\n", tim);
	if (tim == (time_t) -1) {
		ELIBERR(elwix);
		return 2;
	}

	tm = localtime(&tim);
	strftime(str, sizeof str, "%Y-%m-%d %H:%M:%S", tm);
	printf("Time:: %s\n", str);

	return 0;
}

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>