calendar.go ×15

Frontier kind: Code frontier

unlabeled · c_c25b85571ea8

21 tests · 2329 LOC · 112 files · introduces 0 tests · 31 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
15 ranges31 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
346 ranges2329 lines · 112 files · Browse complete extent
All tests (intent)
21 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 31 introduced LOC across 15 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/worker/scheduler/calendar.go 31 introduced LOC · 15 ranges

Open complete file

113 // Returns the earliest time that matches this calendar spec that is after the given time.
114 // All times are considered to have 1 second resolution.
115 > func (cc *compiledCalendar) next(ts time.Time) time.Time { calendar.go
116 > // set time zone
117 > ts = ts.In(cc.tz)
118 >
119 > // get ymdhms from ts
120 > y, mo, d := ts.Date()
121 > h, m, s := ts.Clock()
122 > dstoffset := 0 * time.Hour
123 > if ts.Add(-time.Hour).Hour() == h {
124 // we're in the second copy of a dst repeated hour
125 dstoffset = 1 * time.Hour
127
128 // looking for first matching time after ts, so add 1 second
129 > s++ calendar.go
130 >
131 > Outer:
132 > for {
133 > // normalize after carries
134 > if s >= 60 {
135 m, s = m+1, 0
136 }
137 > if m >= 60 { calendar.go
138 prev := time.Date(y, mo, d, h, 0, 0, 0, cc.tz)
139 h, m = h+1, 0
148 }
149 }
150 > if h >= 24 { calendar.go
151 d, h = d+1, 0
152 }
153 > if d > daysInMonth(mo, y) { calendar.go
154 mo, d = mo+1, 1
155 }
156 > if mo > time.December { calendar.go
157 y, mo = y+1, time.January
158 }
159 > if y > maxCalendarYear { calendar.go
160 break Outer
161 }
162 // try to match year, month, etc. from outside in
163 > if !cc.year(y) { calendar.go
164 y, mo, d, h, m, s = y+1, time.January, 1, 0, 0, 0
165 dstoffset = 0
166 continue Outer
167 }
168 > for !cc.month(int(mo)) { calendar.go
169 mo, d, h, m, s = mo+1, 1, 0, 0, 0
170 dstoffset = 0
173 }
174 }
175 > for !cc.dayOfMonth(d) || !cc.dayOfWeek(int(time.Date(y, mo, d, h, m, s, 0, cc.tz).Weekday())) { calendar.go
176 d, h, m, s = d+1, 0, 0, 0
177 dstoffset = 0
180 }
181 }
182 > for !cc.hour(h) { calendar.go
183 h, m, s = h+1, 0, 0
184 dstoffset = 0
187 }
188 }
189 > for !cc.minute(m) { calendar.go
190 m, s = m+1, 0
191 if m >= 60 {
193 }
194 }
195 > for !cc.second(s) { calendar.go
196 s = s + 1
197 if s >= 60 {
200 }
201 // everything matches
202 > nextTs := time.Date(y, mo, d, h, m, s, 0, cc.tz) calendar.go
203 > // we might have reached a nonexistent time that got jumped over by a dst transition.
204 > // we can tell if the hour is different from what we think it should be.
205 > if nextTs.Hour() != h {
206 h, m, s = h+1, 0, 0
207 continue Outer
208 }
209 > return nextTs.Add(dstoffset) calendar.go
210 }
211