# Generated by Django 5.1.7 on 2025-03-21 17:01

from django.db import migrations, models
from django.utils import timezone
from datetime import time, timezone as dt_timezone

def convert_dates_to_datetimes(apps, schema_editor):
    """Convert existing date values to datetime with max time in UTC."""
    Event = apps.get_model('events', 'Event')

    sentinel_time = time(
        11,
        59,
        59,
        999999,
    )

    for event in Event.objects.all():
        if event.date:
            # Create a datetime with our custom sentinel time in UTC
            naive_datetime = timezone.datetime.combine(event.date, sentinel_time)
            # Make it explicitly UTC timezone aware
            aware_datetime = naive_datetime.replace(tzinfo=dt_timezone.utc)
            event.date = aware_datetime
            event.save()



class Migration(migrations.Migration):

    dependencies = [
        ('events', '0004_fix_anime_episode_numbers'),
    ]

    operations = [
        migrations.AlterField(
            model_name='event',
            name='date',
            field=models.DateTimeField(),
        ),
        migrations.RunPython(
            convert_dates_to_datetimes,
            migrations.RunPython.noop
        ),
    ]
