Replies: 1 comment
-
| There isn't a built-in way to render this, but you could probably use a custom utility though: For returning the week of the year: function getWeekNumber(date: CalendarDate, locale: string): number {
  const startOfYear = new CalendarDate(date.calendar, date.year, 1, 1);
  const dayOfWeek = getDayOfWeek(startOfYear, locale);
  const firstThursday = startOfYear.add({days: (11 - dayOfWeek) % 7});
  
  const weekStart = startOfWeek(date, locale);
  const daysDiff = weekStart.compare(startOfWeek(firstThursday, locale));
  
  return Math.floor(daysDiff / 7) + 1;
}For returning the week of the month: function getWeekNumber(date: CalendarDate, locale: string): number {
  const startOfMonth = new CalendarDate(date.calendar, date.year, date.month, 1);
  const monthWeekStart = startOfWeek(startOfMonth, locale);
  const dateWeekStart = startOfWeek(date, locale);
  
  const daysDiff = dateWeekStart.compare(monthWeekStart);
  
  return Math.floor(daysDiff / 7) + 1;
} | 
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
It would be nice if it was possible to show week numbers in calendars.
Beta Was this translation helpful? Give feedback.
All reactions