Files
udyamlinc-api/src/main/java/com/lincfusion/udyamlinc/ingestion/Weeks.java
T
LincPayandClaude Opus 5 1b9b02f2c7 chore: initial commit — UdyamLinc backend, phases A-E
Spring Boot 4 / Java 17 / Postgres. Masters and serving (A), Agmarknet and
climate ingestion (B), feature store with 14 derivations (C), SpEL rule
engine and risk scoring (D).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-06 13:30:14 +05:30

31 lines
915 B
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package com.lincfusion.udyamlinc.ingestion;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.temporal.WeekFields;
/**
* Everything upstream reports daily; everything downstream reads weekly. One
* definition of "week" for both signal tables, so a mandi price and a rainfall
* figure for the same period actually line up.
*/
public final class Weeks {
private Weeks() {}
/** Monday of the ISO week the date falls in. */
public static LocalDate startOf(LocalDate date) {
return date.with(DayOfWeek.MONDAY);
}
/** ISO week number, 1–53. */
public static int isoWeek(LocalDate date) {
return date.get(WeekFields.ISO.weekOfWeekBasedYear());
}
/** ISO week-based year — not always the calendar year at a year boundary. */
public static int isoYear(LocalDate date) {
return date.get(WeekFields.ISO.weekBasedYear());
}
}