gtool5 Fortran 90/95 ライブラリ 1.0.0-rc5
English
Loading...
Searching...
No Matches
dccaldatetochar.f90
Go to the documentation of this file.
1! -*- mode: f90; coding: utf-8 -*-
2!-----------------------------------------------------------------------
3! Copyright (c) 2000-2026 Gtool Development Group. All rights reserved.
4!-----------------------------------------------------------------------
5!>
6!> @author Yasuhiro MORIKAWA
7!> @copyright Copyright (C) GFD Dennou Club, 2009-2026. All rights reserved. <br/>
8!> License is BSD-2-Clause. see [COPYRIGHT](@ref COPYRIGHT) in detail
9!> @en
10!> @brief Convert date into a string
11!> @details
12!> Procedures described in this file are provided from "dc_calendar" module.
13!> @enden
14!>
15!> @ja
16!> @brief 日時の文字列への変換
17!> @details
18!> このファイルに記載される手続き群は dc_calendar モジュールから提供されます.
19!> @endja
20!>
21
22!> @en
23!> @brief Convert date components to string
24!> @details
25!> Convert year, month, day, hour, minute, second into a string
26!> (conformed to gtool4 netCDF Convention
27!> "5.5 Expression of date and time").
28!>
29!> @param[in] year Year
30!> @param[in] month Month
31!> @param[in] day Day
32!> @param[in] hour Hour
33!> @param[in] min Minute
34!> @param[in] sec Second
35!> @param[in] zone Time-zone (difference from UTC)
36!> @return Strings that express date and time.
37!> See gtool4 netCDF Convention 5.5 Expression of date and time for details.
38!> @enden
39!>
40!> @ja
41!> @brief 日時要素を文字列に変換
42!> @details
43!> 年月日時分秒を文字型変数 (gtool4 netCDF 規約「5.5 日時形式」に準拠)
44!> へ変換して返します.
45!>
46!> @param[in] year 年
47!> @param[in] month 月
48!> @param[in] day 日
49!> @param[in] hour 時
50!> @param[in] min 分
51!> @param[in] sec 秒
52!> @param[in] zone UTC からの時差
53!> @return 日時情報を表す文字列.
54!> 表示形式については gtool4 netCDF 規約 5.5 日時形式を参照のこと.
55!> @endja
56function dccaldatetochar1( year, month, day, hour, min, sec, zone ) &
57 & result(result)
58
59 use dc_types, only: string, token, dp
61 use dc_message, only: messagenotify
62 implicit none
63 character(STRING):: result
64 integer, intent(in):: year
65 integer, intent(in):: month
66 integer, intent(in):: day
67 integer, intent(in):: hour
68 integer, intent(in):: min
69 real(dp), intent(in):: sec
70 character(*), intent(in), optional:: zone
71 integer:: csec_len
72 character(STRING):: csec
73 character(TOKEN):: zonew
74continue
75
76 if ( present(zone) ) then
77 zonew = zone
78 else
79 zonew = ''
80 end if
81
82 csec = tochar(sec)
83 csec = roundnum( csec )
84 if ( trim(csec) == '-0.' ) csec = '0.'
85 do while ( index('123456789.', csec(len_trim(csec):len_trim(csec)) ) == 0 )
86 if ( len_trim(csec) < 2 ) exit
87 csec = csec(1:len_trim(csec)-1)
88 end do
89 if (int(sec) > -1 .and. int(sec) < 10) then
90 if (len_trim(csec) >= len(csec)) then
91 csec = '0' // trim(csec(1:len(csec) - 1))
92 else
93 csec = '0' // trim(csec)
94 end if
95 end if
96 csec_len = len(trim(adjustl(csec)))
97 if (csec(csec_len:csec_len) == '.') csec = csec(1:csec_len-1)
98
99 result = cprintf('%04d-%02d-%02dT%02d:%02d:%c%c', &
100 & i=(/year, month, day, hour, min/), &
101 & c1=trim(csec), c2=trim(zonew))
102
103end function dccaldatetochar1
character(string) function dccaldatetochar1(year, month, day, hour, min, sec, zone)
日時の文字列への変換
メッセージの出力
文字型変数の操作
Definition dc_string.f90:83
種別型パラメタを提供します。
Definition dc_types.f90:55
integer, parameter, public token
単語やキーワードを保持する文字型変数の種別型パラメタ
Definition dc_types.f90:128
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ
Definition dc_types.f90:137
integer, parameter, public dp
倍精度実数型変数
Definition dc_types.f90:92