]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/fortran/doc/gfortran/intrinsic-procedures/dateandtime.rst
sphinx: add missing trailing newline
[thirdparty/gcc.git] / gcc / fortran / doc / gfortran / intrinsic-procedures / dateandtime.rst
CommitLineData
c63539ff
ML
1..
2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
5
6.. index:: DATE_AND_TIME, date, current, current date, time, current, current time
7
8.. _date_and_time:
9
10DATE_AND_TIME --- Date and time subroutine
11******************************************
12
13.. function:: DATE_AND_TIME(DATE, TIME, ZONE, VALUES)
14
15 ``DATE_AND_TIME(DATE, TIME, ZONE, VALUES)`` gets the corresponding date and
16 time information from the real-time system clock. :samp:`{DATE}` is
17 ``INTENT(OUT)`` and has form ccyymmdd. :samp:`{TIME}` is ``INTENT(OUT)`` and
18 has form hhmmss.sss. :samp:`{ZONE}` is ``INTENT(OUT)`` and has form (+-)hhmm,
19 representing the difference with respect to Coordinated Universal Time (UTC).
20 Unavailable time and date parameters return blanks.
21
22 :param DATE:
23 (Optional) The type shall be ``CHARACTER(LEN=8)``
24 or larger, and of default kind.
25
26 :param TIME:
27 (Optional) The type shall be ``CHARACTER(LEN=10)``
28 or larger, and of default kind.
29
30 :param ZONE:
31 (Optional) The type shall be ``CHARACTER(LEN=5)``
32 or larger, and of default kind.
33
34 :param VALUES:
35 (Optional) The type shall be ``INTEGER(8)``.
36
37 :return:
38 None
39
40 Standard:
41 Fortran 90 and later
42
43 Class:
44 Subroutine
45
46 Syntax:
47 .. code-block:: fortran
48
49 CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])
50
51 Example:
52 .. code-block:: fortran
53
54 program test_time_and_date
55 character(8) :: date
56 character(10) :: time
57 character(5) :: zone
58 integer,dimension(8) :: values
59 ! using keyword arguments
60 call date_and_time(date,time,zone,values)
61 call date_and_time(DATE=date,ZONE=zone)
62 call date_and_time(TIME=time)
63 call date_and_time(VALUES=values)
64 print '(a,2x,a,2x,a)', date, time, zone
65 print '(8i5)', values
66 end program test_time_and_date
67
68 See also:
69 :ref:`CPU_TIME`,
3ed1b4ce 70 :ref:`SYSTEM_CLOCK`