Add time to Critical Mass
This commit is contained in:
		
							parent
							
								
									a93a84adad
								
							
						
					
					
						commit
						a9cad3c749
					
				| 
						 | 
				
			
			@ -313,13 +313,21 @@ def critical_mass(start_date: date, limit: int = 12) -> list[Event]:
 | 
			
		|||
    events: list[Event] = []
 | 
			
		||||
    current_date = start_date
 | 
			
		||||
 | 
			
		||||
    tz = pytz.timezone("Europe/London")
 | 
			
		||||
    t = time(18, 0)
 | 
			
		||||
 | 
			
		||||
    for _ in range(limit):
 | 
			
		||||
        # Calculate the last Friday of the current month
 | 
			
		||||
        last_friday = current_date + relativedelta(day=31, weekday=FR(-1))
 | 
			
		||||
 | 
			
		||||
        # Include it in the list only if it's on or after the start_date
 | 
			
		||||
        if last_friday >= start_date:
 | 
			
		||||
            events.append(Event(name="critical_mass", date=last_friday))
 | 
			
		||||
            events.append(
 | 
			
		||||
                Event(
 | 
			
		||||
                    name="critical_mass",
 | 
			
		||||
                    date=tz.localize(datetime.combine(last_friday, t)),
 | 
			
		||||
                )
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        # Move to the next month
 | 
			
		||||
        current_date += relativedelta(months=1)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue