<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def update_standings(semester=None, pool_hours=None, moment=None):
 """ This function acts to update a list of PoolHours objects to adjust their current standing based on the time in the semester. Parameters semester : workshift.models.Semester, optional pool_hours : list of workshift.models.PoolHours, optional If None, runs on all pool hours for semester. moment : datetime, optional """

    if semester is None:
        try:
            semester = Semester.objects.get(current=True)
        except (Semester.DoesNotExist, Semester.MultipleObjectsReturned):
            return []

    if moment is None:
        moment = localtime(now())

    if pool_hours is None:
        pool_hours = PoolHours.objects.filter(pool__semester=semester)

    for hours in pool_hours:
        # Don't update hours after the semester ends
        if hours.last_updated and \
           hours.last_updated.date() > semester.end_date:
            continue

        # Calculate the number of periods (n weeks / once per semester) that
        # have passed since last update
        periods = hours.periods_since_last_update(moment=moment)

        # Update the actual standings
        if periods > 0:
            hours.standing -= hours.hours * periods
            hours.last_updated = moment
            hours.save(update_fields=["standing", "last_updated"])