summaryrefslogtreecommitdiff
path: root/src/lib9/ctime.c
blob: e16ad4a5e51632cabac6b7fd3cd299c81fee0d97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright 2011 The Go Authors.  All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build !plan9

#define NOPLAN9DEFINES
#include <u.h>
#include <libc.h>

char*
p9ctime(long t)
{
	static char buf[100];
	time_t tt;
	struct tm *tm;
	
	tt = t;
	tm = localtime(&tt);
	snprint(buf, sizeof buf, "%3.3s %3.3s %02d %02d:%02d:%02d %3.3s %d\n",
		&"SunMonTueWedThuFriSat"[tm->tm_wday*3],
		&"JanFebMarAprMayJunJulAugSepOctNovDec"[tm->tm_mon*3],
		tm->tm_mday,
		tm->tm_hour,
		tm->tm_min,
		tm->tm_sec,
		"XXX",  // tm_zone is unavailable on windows, and no one cares
		tm->tm_year + 1900);
	return buf;
}