gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
dcdatetimezone.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!-----------------------------------------------------------------------
21
53subroutine dcdatetimesetzone(time, zone, err)
54
55 use dc_types, only: string
58 & operator(-), operator(+)
60 use dc_message, only: messagenotify
61 use dc_trace, only: beginsub, endsub
62 use dc_string, only: stoi
63 implicit none
64 type(dc_datetime), intent(inout):: time
65 character(*), intent(in):: zone
66 logical, intent(out), optional:: err
67 type(dc_difftime):: diff, diff_in
68 integer :: stat
69 character(STRING) :: zone_in, cause_c
70 character(*), parameter :: subname = 'DCDateTimeSetZone'
71continue
72 call beginsub(subname, 'time=%c, zone=%c', &
73 & c1=trim(tochar(time)), c2=trim(zone))
74 stat = dc_noerr
75 cause_c = ''
76
77 if (.not. validzone(zone)) then
78 stat = dc_ebadtimezone
79 cause_c = zone
80 if (present(err)) then
81 call messagenotify('W', subname, &
82 & 'zone=<%c> is invalid.', &
83 & c1=trim(zone))
84 else
85 goto 999
86 end if
87 end if
88
89 call eval(time, zone = zone_in)
90 diff_in = zonetodiff(zone_in)
91 diff = zonetodiff(zone)
92
93 time = time + (diff_in - diff)
94 time % zone = zone
95
96999 continue
97 call storeerror(stat, subname, err, cause_c)
98 call endsub(subname, 'time=%c', &
99 & c1=trim(tochar(time)))
100end subroutine dcdatetimesetzone
101
123function dcdatetimezonetodiff(zone) result(diff)
124
125 use dc_date_types, only: dc_difftime
127 use dc_string, only: stoi
128 implicit none
129 type(dc_difftime):: diff
130 character(*), intent(in):: zone
131 integer:: hour, min, sgn
132continue
133 if (.not. validzone(zone)) then
134 call dcdifftimecreate(diff)
135 else
136 if (zone(1:1) == '-') then
137 sgn = 1
138 else
139 sgn = -1
140 end if
141 hour = stoi(zone(2:3))
142 min = stoi(zone(5:6))
143 call dcdifftimecreate(diff, hour = hour * sgn, min = min * sgn)
144 end if
145end function dcdatetimezonetodiff
146
173function dcdatetimevalidzone(zone) result(result)
174
175 implicit none
176 character(*), intent(in):: zone
177 logical:: result
178continue
179 result = .false.
180 if (len(zone) < 6) return
181 if (verify(zone(1:1), '+-') /= 0) return
182 if (verify(zone(2:3), '1234567890') /= 0) return
183 if (verify(zone(5:6), '1234567890') /= 0) return
184 if (zone(4:4) /= ':') return
185 result = .true.
186end function dcdatetimevalidzone
type(dc_difftime) function dcdatetimezonetodiff(zone)
logical function dcdatetimevalidzone(zone)
subroutine dcdatetimesetzone(time, zone, err)
Procedures for timezone handling.
Interface declarations for procedures provided from dc_date.
Derived types and parameters for date and time.
Error handling module.
Definition dc_error.f90:454
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition dc_error.f90:891
integer, parameter, public dc_noerr
Error storage variables
Definition dc_error.f90:468
integer, parameter, public dc_ebadtimezone
Definition dc_error.f90:538
Message output module.
Handling character types.
Definition dc_string.f90:83
Debug tracing module.
Definition dc_trace.f90:150
subroutine, public beginsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca, version)
Definition dc_trace.f90:457
subroutine, public endsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:580
Provides kind type parameter values.
Definition dc_types.f90:55
integer, parameter, public string
Character length for string
Definition dc_types.f90:137