The ParaMonte Documentation Website
Current view: top level - kernel - DateTime_mod.f90 (source / functions) Hit Total Coverage
Test: ParaMonte 1.5.1 :: MPI Parallel Kernel - Code Coverage Report Lines: 17 17 100.0 %
Date: 2021-01-08 13:07:16 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       2             : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       3             : !!!!
       4             : !!!!   MIT License
       5             : !!!!
       6             : !!!!   ParaMonte: plain powerful parallel Monte Carlo library.
       7             : !!!!
       8             : !!!!   Copyright (C) 2012-present, The Computational Data Science Lab
       9             : !!!!
      10             : !!!!   This file is part of the ParaMonte library.
      11             : !!!!
      12             : !!!!   Permission is hereby granted, free of charge, to any person obtaining a
      13             : !!!!   copy of this software and associated documentation files (the "Software"),
      14             : !!!!   to deal in the Software without restriction, including without limitation
      15             : !!!!   the rights to use, copy, modify, merge, publish, distribute, sublicense,
      16             : !!!!   and/or sell copies of the Software, and to permit persons to whom the
      17             : !!!!   Software is furnished to do so, subject to the following conditions:
      18             : !!!!
      19             : !!!!   The above copyright notice and this permission notice shall be
      20             : !!!!   included in all copies or substantial portions of the Software.
      21             : !!!!
      22             : !!!!   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
      23             : !!!!   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
      24             : !!!!   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
      25             : !!!!   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
      26             : !!!!   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
      27             : !!!!   OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
      28             : !!!!   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
      29             : !!!!
      30             : !!!!   ACKNOWLEDGMENT
      31             : !!!!
      32             : !!!!   ParaMonte is an honor-ware and its currency is acknowledgment and citations.
      33             : !!!!   As per the ParaMonte library license agreement terms, if you use any parts of
      34             : !!!!   this library for any purposes, kindly acknowledge the use of ParaMonte in your
      35             : !!!!   work (education/research/industry/development/...) by citing the ParaMonte
      36             : !!!!   library as described on this page:
      37             : !!!!
      38             : !!!!       https://github.com/cdslaborg/paramonte/blob/main/ACKNOWLEDGMENT.md
      39             : !!!!
      40             : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      41             : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      42             : 
      43             : !>  \brief This module contains classes and procedures for computing the date and time.
      44             : !>  \author Amir Shahmoradi
      45             : 
      46             : module DateTime_mod
      47             : 
      48             :     implicit none
      49             : 
      50             :     public
      51             :     private :: queryDateTime
      52             : 
      53             :     character(*), parameter :: MODULE_NAME = "@DateTime_mod"
      54             : 
      55             :     !> The datetime_type class
      56             :     type, public :: DateTime_type
      57             :         character(8)    :: date
      58             :         character(10)   :: time
      59             :         character(5)    :: zone
      60             :         integer         :: Values(8)
      61             :         character(2)    :: century
      62             :         character(4)    :: year
      63             :         character(2)    :: month
      64             :         character(2)    :: day
      65             :         character(2)    :: hour
      66             :         character(2)    :: minute
      67             :         character(2)    :: second
      68             :         character(3)    :: millisecond
      69             :         character(21)   :: fancyStyleBasic
      70             :         character(35)   :: fancyStyle
      71             :     contains
      72             :         !> Query date and time.
      73             :         procedure, pass :: query => queryDateTime
      74             :     end type DateTime_type
      75             : 
      76             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      77             : 
      78             : contains
      79             : 
      80             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      81             : 
      82             :     !> Function to query the [DateTime_type](@ref datetime_type) instance to the current time.
      83             :     !>
      84             :     !> @param[in,out]   self : An object of [DateTime_type](@ref datetime_type) class.
      85        1157 :     subroutine queryDateTime(self)
      86             : #if INTEL_COMPILER_ENABLED && defined DLL_ENABLED && (OS_IS_WINDOWS || defined OS_IS_DARWIN)
      87             :         !DEC$ ATTRIBUTES DLLEXPORT :: queryDateTime
      88             : #endif
      89             :         implicit none
      90             :         class(DateTime_type), intent(inout) :: self
      91             :         call date_and_time( date    = self%date   &
      92             :                           , time    = self%time   &
      93             :                           , zone    = self%zone   &
      94             :                           , Values  = self%Values &
      95        1157 :                           )
      96        1157 :         self%century            = self%date(1:2)
      97        1157 :         self%year               = self%date(1:4)
      98        1157 :         self%month              = self%date(5:6)
      99        1157 :         self%day                = self%date(7:8)
     100        1157 :         self%hour               = self%time(1:2)
     101        1157 :         self%minute             = self%time(3:4)
     102        1157 :         self%second             = self%time(5:6)
     103        1157 :         self%millisecond        = self%time(8:10)
     104             :         self%fancyStyleBasic    = self%year // "/" // &             ! 5 characters
     105             :                                   self%month // "/" // &            ! 3 characters
     106             :                                   self%day //" - " // &             ! 5 characters
     107             :                                   self%hour // ":" // &             ! 3 characters
     108             :                                   self%minute // ":" // &           ! 3 characters
     109        1157 :                                   self%second                       ! 2 characters
     110             :         self%fancyStyle         = self%fancyStyleBasic // "." // &  ! basic+1 characters
     111             :                                   self%millisecond // " " // &      ! 4 characters
     112        1157 :                                   self%zone // " UTC"               ! 9 characters
     113        1157 :     end subroutine queryDateTime
     114             : 
     115             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     116             : 
     117             :     !> Return date and time in a nice format.
     118             :     !>
     119             :     !> \return
     120             :     !> A character vector containing date and time in a nice format.
     121             :     !>
     122             :     !> \remark
     123             :     !> This is an impure function due to its dependence on `date_and_time()` Fortran intrinsic function.
     124         503 :     function getNiceDateTime() result(niceDateTime)
     125             : #if INTEL_COMPILER_ENABLED && defined DLL_ENABLED && (OS_IS_WINDOWS || defined OS_IS_DARWIN)
     126             :         !DEC$ ATTRIBUTES DLLEXPORT :: getNiceDateTime
     127             : #endif
     128             :         implicit none
     129             :         character(len=21)                        :: niceDateTime
     130             :         character(10)                            :: time
     131             :         character(8)                             :: date
     132         503 :         call date_and_time(date,time)
     133         503 :         niceDateTime = date(1:4)//'/'//date(5:6)//'/'//date(7:8)//' - '//time(1:2)//':'//time(3:4)//':'//time(5:6)
     134        1157 :     end function getNiceDateTime
     135             : 
     136             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     137             : 
     138             : end module DateTime_mod ! LCOV_EXCL_LINE

ParaMonte: Plain Powerful Parallel Monte Carlo Library 
The Computational Data Science Lab
© Copyright 2012 - 2021