Skip to content

Commit 0b59147

Browse files
jasmith-hsclaude
andcommitted
Delegate all public ZonedDateTime instance methods on PyishDate
JinjavaInterpreterResolver wraps ZonedDateTime results back into PyishDate, so the delegate methods return raw ZonedDateTime to keep the PyishDate implementation clean. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4891843 commit 0b59147

1 file changed

Lines changed: 245 additions & 0 deletions

File tree

src/main/java/com/hubspot/jinjava/objects/date/PyishDate.java

Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,24 @@
77
import com.hubspot.jinjava.objects.serialization.PyishSerializable;
88
import java.io.IOException;
99
import java.io.Serializable;
10+
import java.time.DayOfWeek;
1011
import java.time.Instant;
12+
import java.time.LocalDate;
13+
import java.time.LocalDateTime;
14+
import java.time.LocalTime;
15+
import java.time.OffsetDateTime;
16+
import java.time.ZoneId;
1117
import java.time.ZoneOffset;
1218
import java.time.ZonedDateTime;
19+
import java.time.format.DateTimeFormatter;
1320
import java.time.temporal.ChronoField;
21+
import java.time.temporal.Temporal;
22+
import java.time.temporal.TemporalAdjuster;
23+
import java.time.temporal.TemporalAmount;
24+
import java.time.temporal.TemporalField;
25+
import java.time.temporal.TemporalQuery;
26+
import java.time.temporal.TemporalUnit;
27+
import java.time.temporal.ValueRange;
1428
import java.util.Date;
1529
import java.util.Objects;
1630
import java.util.Optional;
@@ -115,6 +129,237 @@ public int getMicrosecond() {
115129
return date.get(ChronoField.MILLI_OF_SECOND);
116130
}
117131

132+
// ZonedDateTime delegate methods
133+
134+
public ZoneId getZone() {
135+
return date.getZone();
136+
}
137+
138+
public ZoneOffset getOffset() {
139+
return date.getOffset();
140+
}
141+
142+
public ZonedDateTime withZoneSameLocal(ZoneId zone) {
143+
return date.withZoneSameLocal(zone);
144+
}
145+
146+
public ZonedDateTime withZoneSameInstant(ZoneId zone) {
147+
return date.withZoneSameInstant(zone);
148+
}
149+
150+
public ZonedDateTime withFixedOffsetZone() {
151+
return date.withFixedOffsetZone();
152+
}
153+
154+
public ZonedDateTime withEarlierOffsetAtOverlap() {
155+
return date.withEarlierOffsetAtOverlap();
156+
}
157+
158+
public ZonedDateTime withLaterOffsetAtOverlap() {
159+
return date.withLaterOffsetAtOverlap();
160+
}
161+
162+
public LocalDateTime toLocalDateTime() {
163+
return date.toLocalDateTime();
164+
}
165+
166+
public LocalDate toLocalDate() {
167+
return date.toLocalDate();
168+
}
169+
170+
public LocalTime toLocalTime() {
171+
return date.toLocalTime();
172+
}
173+
174+
public OffsetDateTime toOffsetDateTime() {
175+
return date.toOffsetDateTime();
176+
}
177+
178+
@Override
179+
public Instant toInstant() {
180+
return date.toInstant();
181+
}
182+
183+
public boolean isSupported(TemporalField field) {
184+
return date.isSupported(field);
185+
}
186+
187+
public boolean isSupported(TemporalUnit unit) {
188+
return date.isSupported(unit);
189+
}
190+
191+
public ValueRange range(TemporalField field) {
192+
return date.range(field);
193+
}
194+
195+
public int get(TemporalField field) {
196+
return date.get(field);
197+
}
198+
199+
public long getLong(TemporalField field) {
200+
return date.getLong(field);
201+
}
202+
203+
public int getMonthValue() {
204+
return date.getMonthValue();
205+
}
206+
207+
public int getDayOfMonth() {
208+
return date.getDayOfMonth();
209+
}
210+
211+
public int getDayOfYear() {
212+
return date.getDayOfYear();
213+
}
214+
215+
public DayOfWeek getDayOfWeek() {
216+
return date.getDayOfWeek();
217+
}
218+
219+
public int getNano() {
220+
return date.getNano();
221+
}
222+
223+
public ZonedDateTime with(TemporalAdjuster adjuster) {
224+
return date.with(adjuster);
225+
}
226+
227+
public ZonedDateTime with(TemporalField field, long newValue) {
228+
return date.with(field, newValue);
229+
}
230+
231+
public ZonedDateTime withYear(int year) {
232+
return date.withYear(year);
233+
}
234+
235+
public ZonedDateTime withMonth(int month) {
236+
return date.withMonth(month);
237+
}
238+
239+
public ZonedDateTime withDayOfMonth(int dayOfMonth) {
240+
return date.withDayOfMonth(dayOfMonth);
241+
}
242+
243+
public ZonedDateTime withDayOfYear(int dayOfYear) {
244+
return date.withDayOfYear(dayOfYear);
245+
}
246+
247+
public ZonedDateTime withHour(int hour) {
248+
return date.withHour(hour);
249+
}
250+
251+
public ZonedDateTime withMinute(int minute) {
252+
return date.withMinute(minute);
253+
}
254+
255+
public ZonedDateTime withSecond(int second) {
256+
return date.withSecond(second);
257+
}
258+
259+
public ZonedDateTime withNano(int nanoOfSecond) {
260+
return date.withNano(nanoOfSecond);
261+
}
262+
263+
public ZonedDateTime truncatedTo(TemporalUnit unit) {
264+
return date.truncatedTo(unit);
265+
}
266+
267+
public ZonedDateTime plus(TemporalAmount amountToAdd) {
268+
return date.plus(amountToAdd);
269+
}
270+
271+
public ZonedDateTime plus(long amountToAdd, TemporalUnit unit) {
272+
return date.plus(amountToAdd, unit);
273+
}
274+
275+
public ZonedDateTime plusYears(long years) {
276+
return date.plusYears(years);
277+
}
278+
279+
public ZonedDateTime plusMonths(long months) {
280+
return date.plusMonths(months);
281+
}
282+
283+
public ZonedDateTime plusWeeks(long weeks) {
284+
return date.plusWeeks(weeks);
285+
}
286+
287+
public ZonedDateTime plusDays(long days) {
288+
return date.plusDays(days);
289+
}
290+
291+
public ZonedDateTime plusHours(long hours) {
292+
return date.plusHours(hours);
293+
}
294+
295+
public ZonedDateTime plusMinutes(long minutes) {
296+
return date.plusMinutes(minutes);
297+
}
298+
299+
public ZonedDateTime plusSeconds(long seconds) {
300+
return date.plusSeconds(seconds);
301+
}
302+
303+
public ZonedDateTime plusNanos(long nanos) {
304+
return date.plusNanos(nanos);
305+
}
306+
307+
public ZonedDateTime minus(TemporalAmount amountToSubtract) {
308+
return date.minus(amountToSubtract);
309+
}
310+
311+
public ZonedDateTime minus(long amountToSubtract, TemporalUnit unit) {
312+
return date.minus(amountToSubtract, unit);
313+
}
314+
315+
public ZonedDateTime minusYears(long years) {
316+
return date.minusYears(years);
317+
}
318+
319+
public ZonedDateTime minusMonths(long months) {
320+
return date.minusMonths(months);
321+
}
322+
323+
public ZonedDateTime minusWeeks(long weeks) {
324+
return date.minusWeeks(weeks);
325+
}
326+
327+
public ZonedDateTime minusDays(long days) {
328+
return date.minusDays(days);
329+
}
330+
331+
public ZonedDateTime minusHours(long hours) {
332+
return date.minusHours(hours);
333+
}
334+
335+
public ZonedDateTime minusMinutes(long minutes) {
336+
return date.minusMinutes(minutes);
337+
}
338+
339+
public ZonedDateTime minusSeconds(long seconds) {
340+
return date.minusSeconds(seconds);
341+
}
342+
343+
public ZonedDateTime minusNanos(long nanos) {
344+
return date.minusNanos(nanos);
345+
}
346+
347+
public <R> R query(TemporalQuery<R> query) {
348+
return date.query(query);
349+
}
350+
351+
public long until(Temporal endExclusive, TemporalUnit unit) {
352+
return date.until(endExclusive, unit);
353+
}
354+
355+
public String format(DateTimeFormatter formatter) {
356+
return date.format(formatter);
357+
}
358+
359+
public long toEpochSecond() {
360+
return date.toEpochSecond();
361+
}
362+
118363
public String getDateFormat() {
119364
return dateFormat;
120365
}

0 commit comments

Comments
 (0)