github.com/rohankumardubey/syslog-redirector-golang@v0.0.0-20140320174030-4859f03d829a/src/lib9/ctime.c (about) 1 // Copyright 2011 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 #define NOPLAN9DEFINES 6 #include <u.h> 7 #include <libc.h> 8 9 char* 10 p9ctime(long t) 11 { 12 static char buf[100]; 13 time_t tt; 14 struct tm *tm; 15 16 tt = t; 17 tm = localtime(&tt); 18 snprint(buf, sizeof buf, "%3.3s %3.3s %02d %02d:%02d:%02d %3.3s %d\n", 19 &"SunMonTueWedThuFriSat"[tm->tm_wday*3], 20 &"JanFebMarAprMayJunJulAugSepOctNovDec"[tm->tm_mon*3], 21 tm->tm_mday, 22 tm->tm_hour, 23 tm->tm_min, 24 tm->tm_sec, 25 "XXX", // tm_zone is unavailable on windows, and no one cares 26 tm->tm_year + 1900); 27 return buf; 28 }