Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
std::tm(3)		      C++ Standard Libary		    std::tm(3)

NAME
       std::tm - std::tm

Synopsis
	  Defined in header <ctime>
	  struct tm;

	  Structure holding a calendar date and	time broken down into its com-
       ponents.

Member objects
		       seconds after the minute
		       [0, 61]
	  int tm_sec   (until C++11)
		       [0, 60]
		       (since C++11)^[note 1]
		       (public member object)
	  int tm_min   minutes after the hour  [0, 59]
		       (public member object)
	  int tm_hour  hours since midnight  [0, 23]
		       (public member object)
	  int tm_mday  day of the month	 [1, 31]
		       (public member object)
	  int tm_mon   months since January  [0, 11]
		       (public member object)
	  int tm_year  years since 1900
		       (public member object)
	  int tm_wday  days since Sunday  [0, 6]
		       (public member object)
	  int tm_yday  days since January 1  [0, 365]
		       (public member object)
		       Daylight	Saving Time flag. The value is positive	if DST
       is in effect,
	  int tm_isdst zero if not and negative	if no information is available
		       (public member object)

Notes
	  The  Standard	 mandates only the presence of the aforementioned mem-
       bers in either
	  order. The implementations usually add  more	data-members  to  this
       structure.

	   1.	Range  allows  for a positive leap second. Two leap seconds in
       the same	minute
	      are not allowed (the range 0..61 was a defect introduced in  C89
       and corrected in
	      C99)

Example
	  Show the start of calendar time.

       // Run this code

	#include <ctime>
	#include <iostream>

	int main()
	{
	    std::tm start{};
	    start.tm_mday = 1;

	    std::mktime(&start);
	    std::cout << std::asctime(&start)
		      << "sizeof(std::tm) = "
		      << sizeof(std::tm) << '\n';
	}

Possible output:
	Mon Jan	 1 00:00:00 1900
	sizeof(std::tm)	= 56

See also
	  localtime  converts  time  since epoch to calendar time expressed as
       local time
		    (function)
		    converts time since	epoch to calendar  time	 expressed  as
       Universal
	  gmtime    Coordinated	Time
		    (function)

http://cppreference.com		  2022.07.31			    std::tm(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::tm&sektion=3&manpath=FreeBSD+Ports+15.0>

home | help