rewrite code for function update_table in code: 

from PySide6.QtCore import QTime
from PySide6.QtWidgets import QApplication, QWidget, QCalendarWidget, QTableWidget, QTableWidgetItem, QVBoxLayout
class PlannerWidget(QWidget):
    def __init__(self):
        super().__init__()

        # Create calendar widget
        self.calendar = QCalendarWidget()
        self.calendar.setGridVisible(True)
        self.calendar.selectionChanged.connect(self.update_table)

        # Create table widget
        self.table = QTableWidget()
        self.table.setRowCount(24)  # 24 hours in a day
        self.table.setColumnCount(2)  # 2 columns: time and task
        self.table.setColumnWidth(0, 50)  # Time column width
        self.table.setHorizontalHeaderLabels(['Time', 'Task'])
        self.table.verticalHeader().setVisible(False)
        self.table.setEditTriggers(QTableWidget.NoEditTriggers)  # Disable editing

        # Add time slots to table widget
        for row in range(24):
            time_item = QTableWidgetItem(QTime(row, 0).toString('h:mm AP'))
            self.table.setItem(row, 0, time_item)

        # Add widgets to layout
        layout = QVBoxLayout()
        layout.addWidget(self.calendar)
        layout.addWidget(self.table)
        self.setLayout(layout)
    def update_table(self):
        # Clear table
        self.table.clearContents()
        # Get selected date
        selected_date = self.calendar.selectedDate()
        # Add time slots to table widget for selected date
        for row in range(24)