Now Function

public function Now() result(time)

Gets a DateTime object that is set to the current date and time on this computer, expressed as the local time.

Arguments

None

Return Value type(DateTime)


Variables

Type Visibility Attributes Name Initial
character(len=8), public :: systemDate
character(len=10), public :: systemTime
integer(kind=short), public :: values(8)
character(len=5), public :: zone

Source Code

FUNCTION  Now &
!
() &
!
RESULT (time)

USE StringManipulation, ONLY: &
!Imported routines
StringToShort

IMPLICIT NONE

! Local variables:
TYPE (DateTime) :: time

! Local scalars:
CHARACTER ( LEN = 8 )  :: systemDate
CHARACTER ( LEN = 10 ) :: systemTime
INTEGER (KIND = short) :: values(8)
CHARACTER ( LEN = 5 )  :: zone
!------------end of declaration------------------------------------------------
 
  CALL date_and_time ( systemDate, systemTime, zone, values )

  time % year = values(1)
  time % month = values(2)
  time % day = values(3)
  time % hour = values(5)
  time % minute = values(6)
  time % second = values(7)
  time % TZhour = StringToShort ( zone (2:3) )
  time % TZminute = StringToShort ( zone (4:5) )
  time % TZsign = zone (1:1)
  
END FUNCTION Now