def timed_weighting(ledger, global_slot_start, slots_per_epoch):
    """Takes in a staking ledger and determines the timed factor for the account"""
    if not ledger["timing"]:
        # Untimed for full epoch so we have the maximum weighting of 1
        return 1
    else:
        # This is timed at the end of the epoch so we always return 0
        if ledger["timing"]["timed_epoch_end"]:
            return 0
        else:
            # This must be timed for only a portion of the epoch
            timed_end = ledger["timing"]["untimed_slot"]
            global_slot_end = global_slot_start + slots_per_epoch

            return ((global_slot_end - timed_end) / slots_per_epoch)