Path: blob/main/cddl/contrib/opensolaris/cmd/stat/common/timestamp.c
39492 views
/*1* CDDL HEADER START2*3* The contents of this file are subject to the terms of the4* Common Development and Distribution License (the "License").5* You may not use this file except in compliance with the License.6*7* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE8* or http://www.opensolaris.org/os/licensing.9* See the License for the specific language governing permissions10* and limitations under the License.11*12* When distributing Covered Code, include this CDDL HEADER in each13* file and include the License file at usr/src/OPENSOLARIS.LICENSE.14* If applicable, add the following below this CDDL HEADER, with the15* fields enclosed by brackets "[]" replaced with your own identifying16* information: Portions Copyright [yyyy] [name of copyright owner]17*18* CDDL HEADER END19*/20/*21* Copyright 2009 Sun Microsystems, Inc. All rights reserved.22* Use is subject to license terms.23*/2425#include "statcommon.h"2627#include <langinfo.h>2829/*30* Print timestamp as decimal reprentation of time_t value (-T u was specified)31* or in date(1) format (-T d was specified).32*/33void34print_timestamp(uint_t timestamp_fmt)35{36time_t t = time(NULL);3738if (timestamp_fmt == UDATE) {39(void) printf("%ld\n", t);40} else if (timestamp_fmt == DDATE) {41char dstr[64];42int len;4344len = strftime(dstr, sizeof (dstr), "%+", localtime(&t));45if (len > 0)46(void) printf("%s\n", dstr);47}48}495051