1.\" $OpenBSD: timespec_get.3,v 1.3 2018/10/31 17:05:54 deraadt Exp $ 2.\" $NetBSD: timespec_get.3,v 1.4 2018/08/13 06:08:48 wiz Exp $ 3.\" 4.\" Copyright (c) 2016 The NetBSD Foundation, Inc. 5.\" All rights reserved. 6.\" 7.\" This code is derived from software contributed to The NetBSD Foundation 8.\" by Kamil Rytarowski. 9.\" 10.\" Redistribution and use in source and binary forms, with or without 11.\" modification, are permitted provided that the following conditions 12.\" are met: 13.\" 1. Redistributions of source code must retain the above copyright 14.\" notice, this list of conditions and the following disclaimer. 15.\" 2. Redistributions in binary form must reproduce the above copyright 16.\" notice, this list of conditions and the following disclaimer in the 17.\" documentation and/or other materials provided with the distribution. 18.\" 19.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29.\" POSSIBILITY OF SUCH DAMAGE. 30.\" 31.Dd $Mdocdate: October 31 2018 $ 32.Dt TIMESPEC_GET 3 33.Os 34.Sh NAME 35.Nm timespec_get 36.Nd get current calendar time 37.Sh SYNOPSIS 38.In time.h 39.Ft int 40.Fn timespec_get "struct timespec *ts" "int base" 41.Sh DESCRIPTION 42The 43.Fn timespec_get 44function sets the interval pointed to by 45.Fa ts 46to hold the current calendar time based on the specified time base in 47.Fa base . 48.Pp 49The base 50.Dv TIME_UTC 51returns the time since the Epoch. 52This time is expressed in seconds and nanoseconds since midnight (0 hour), 53January 1, 1970. 54In 55.Ox , 56this corresponds to 57.Dv CLOCK_REALTIME . 58.Sh RETURN VALUES 59The 60.Nm 61function returns the passed value of 62.Fa base 63if successful, otherwise 64.Dv 0 65on failure. 66.Sh SEE ALSO 67.Xr clock_gettime 2 , 68.Xr gettimeofday 2 , 69.Xr time 3 70.Sh STANDARDS 71The 72.Nm 73function with a 74.Fa base 75of 76.Dv TIME_UTC 77conforms to 78.St -isoC-2011 . 79.Sh HISTORY 80The 81.Fn timespec_get 82function was ported from 83.Nx 84and first appeared in 85.Ox 6.5 . 86