2 * See the file LICENSE for redistribution information.
4 * Copyright (c) 2001-2009 Oracle. All rights reserved.
13 static void __os_brew_ct_numb __P((char *, int));
17 * Format a time-stamp.
20 __os_ctime(tod, time_buf)
28 strcpy(time_buf, "Thu Jan 01 00:00:00 1970");
29 time_buf[CTIME_BUFLEN - 1] = '\0';
32 * Berkeley DB uses POSIX time values internally, convert to a BREW
35 tt = *tod - BREW_EPOCH_OFFSET + LOCALTIMEOFFSET(NULL);
36 GETJULIANDATE(tt, &jt);
39 * wWeekDay : Day of the week 0-6 (0=Monday, 6=Sunday)
41 ncp = &"MonTueWedThuFriSatSun"[jt.wWeekDay*3];
45 ncp = &"JanFebMarAprMayJunJulAugSepOctNovDec"[(jt.wMonth - 1) * 3];
50 __os_brew_ct_numb(time_buf + 8, jt.wDay);
51 /* Add 100 to keep the leading zero. */
52 __os_brew_ct_numb(time_buf + 11, jt.wHour + 100);
53 __os_brew_ct_numb(time_buf + 14, jt.wMinute + 100);
54 __os_brew_ct_numb(time_buf + 17, jt.wSecond + 100);
56 if (jt.wYear < 100) { /* 9 99 */
59 __os_brew_ct_numb(time_buf + 22, jt.wYear);
60 } else { /* 99 1999 */
61 __os_brew_ct_numb(time_buf + 20, jt.wYear / 100);
62 __os_brew_ct_numb(time_buf + 22, jt.wYear % 100 + 100);
69 * __os_brew_ct_numb --
70 * Append ASCII representations for two digits to a string.
73 __os_brew_ct_numb(cp, n)
79 cp[0] = (n / 10) % 10 + '0';