public function display()
    {
        if (!$this->visible) {
            return;
        }

        parent::display();

        $div_tag = new SwatHtmlTag('div');
        $div_tag->id = $this->id;
        $div_tag->class = $this->getCSSClassString();
        $div_tag->open();

        echo '<span class="swat-time-entry-span">';

        if ($this->display_parts & self::HOUR) {
            $hour_flydown = $this->getCompositeWidget('hour_flydown');
            if ($hour_flydown->value === null && $this->value !== null) {
                // work around a bug in PEAR::Date that returns hour as a string
                $hour = intval($this->value->getHour());

                // convert 24-hour value to 12-hour display
                if ($this->twelve_hour) {
                    if ($hour > 12) {
                        $hour -= 12;
                    }

                    if ($hour === 0) {
                        $hour = 12;
                    }
                }

                $hour_flydown->value = $hour;
            }

            $hour_flydown->display();

            if ($this->display_parts & (self::MINUTE | self::SECOND)) {
                echo ':';
            }
        }

        if ($this->display_parts & self::MINUTE) {
            $minute_flydown = $this->getCompositeWidget('minute_flydown');
            if ($minute_flydown->value === null && $this->value !== null) {
                // work around a bug in PEAR::Date that returns minutes as a
                // 2-character string
                $minute = intval($this->value->getMinute());
                $minute_flydown->value = $minute;
            }

            $minute_flydown->display();
            if ($this->display_parts & self::SECOND) {
                echo ':';
            }
        }

        if ($this->display_parts & self::SECOND) {
            $second_flydown = $this->getCompositeWidget('second_flydown');
            if ($second_flydown->value === null && $this->value !== null) {
                $second_flydown->value = $this->value->getSecond();
            }

            $second_flydown->display();
        }

        if ($this->display_parts & self::HOUR && $this->twelve_hour) {
            $am_pm_flydown = $this->getCompositeWidget('am_pm_flydown');
            if ($am_pm_flydown->value === null && $this->value !== null) {
                $am_pm_flydown->value =
                    $this->value->getHour() < 12 ? 'am' : 'pm';
            }

            $am_pm_flydown->display();
        }

        echo '</span>';

        Swat::displayInlineJavaScript($this->getInlineJavaScript());

        $div_tag->close();
    }