/* Build Day Table
-----------------------------------------------------------------------
10788
function buildDayTable() {
		var html = buildDayTableHTML();

		if (dayTable) {
			dayTable.remove();
		}
		dayTable = $(html).appendTo(element);

		dayHead = dayTable.find('thead');
		dayHeadCells = dayHead.find('th').slice(1, -1); // exclude gutter
		dayBody = dayTable.find('tbody');
		dayBodyCells = dayBody.find('td').slice(0, -1); // exclude gutter
		dayBodyCellInners = dayBodyCells.find('> div');
		dayBodyCellContentInners = dayBodyCells.find('.fc-day-content > div');

		dayBodyFirstCell = dayBodyCells.eq(0);
		dayBodyFirstCellStretcher = dayBodyCellInners.eq(0);
		
		markFirstLast(dayHead.add(dayHead.find('tr')));
		markFirstLast(dayBody.add(dayBody.find('tr')));

		// TODO: now that we rebuild the cells every time, we should call dayRender
	}
1024644
public function build()
    {
        $trigger = new DailyTimeIntervalTrigger();
        $trigger->setRepeatInterval($this->interval);
        $trigger->setRepeatIntervalUnit($this->intervalUnit);
        $trigger->setMisfireInstruction($this->misfireInstruction);
        $trigger->setRepeatCount($this->repeatCount);

        if (null != $this->daysOfWeek) {
            $trigger->setDaysOfWeek($this->daysOfWeek);
        } else {
            $trigger->setDaysOfWeek(DailyTimeIntervalTrigger::ALL_DAYS_OF_THE_WEEK);
        }

        $now = new \DateTime();

        if (null != $this->startTimeOfDay) {
            $trigger->setStartTimeOfDay($this->startTimeOfDay);
        } else {
            $startTimeOfDay = clone $now;
            $startTimeOfDay->setTime(0, 0, 0);

            $trigger->setStartTimeOfDay($startTimeOfDay);
        }

        if(null != $this->endTimeOfDay) {
            $trigger->setEndTimeOfDay($this->endTimeOfDay);
        } else {
            $endTimeOfDay = clone $now;
            $endTimeOfDay->setTime(23, 59, 59);
        }

        return $trigger;
    }
500133
public void setDay(Day d)
   {
      if (m_day != null)
      {
         m_parentCalendar.removeHoursFromDay(this);
      }

      m_day = d;

      m_parentCalendar.attachHoursToDay(this);
   }
566224
function (table) {
			var time;
			
			if (!table) {
				time = Date['now']? Date['now']() : new Date().getTime();
				
			} else {
				var day, month, year, hour, min, sec;
				
				if (!(day = table.getMember('day'))) throw new shine.Error("Field 'day' missing in date table");
				if (!(month = table.getMember('month'))) throw new shine.Error("Field 'month' missing in date table");
				if (!(year = table.getMember('year'))) throw new shine.Error("Field 'year' missing in date table");
				hour = table.getMember('hour') || 12;
				min = table.getMember('min') || 0;
				sec = table.getMember('sec') || 0;
				
				if (table.getMember('isdst')) hour--;
				time = new Date(year, month - 1, day, hour, min, sec).getTime();
			}
			
			return Math.floor(time / 1000);
		}
39440
@Nonnull
  public Date build ()
  {
    Calendar cal;
    if (m_aTZ != null && m_aLocale != null)
      cal = Calendar.getInstance (m_aTZ, m_aLocale);
    else
      if (m_aTZ != null)
        cal = Calendar.getInstance (m_aTZ, Locale.getDefault (Locale.Category.FORMAT));
      else
        if (m_aLocale != null)
          cal = Calendar.getInstance (TimeZone.getDefault (), m_aLocale);
        else
          cal = PDTFactory.createCalendar ();

    cal.set (Calendar.YEAR, m_nYear);
    cal.set (Calendar.MONTH, m_nMonth - 1);
    cal.set (Calendar.DAY_OF_MONTH, m_nDay);
    cal.set (Calendar.HOUR_OF_DAY, m_nHour);
    cal.set (Calendar.MINUTE, m_nMinute);
    cal.set (Calendar.SECOND, m_nSecond);
    cal.set (Calendar.MILLISECOND, 0);
    return cal.getTime ();
  }
456190
private function _buildDates()
    {
        if ( !$this->from || !$this->to || $this->from > $this->to ) {
            return;
        }
        $this->dates = array();
        $d = clone $this->from;
        $this->dates[] = clone $d;
        while ( $d != $this->to ) {
            $d->add(new \DateInterval('P1D'));
            $this->dates[] = clone $d;
        }
    }
1163533
public function createSQL()
	{
		try {

			$lines = array();

			$indices = array();

			$columns = $this->columns;

			$template = "CREATE TABLE %s (\n%s,\n%s\n) ENGINE=%s DEFAULT CHARSET=%s;";

			foreach ($this->columns as $column_name => $column)
			{

				//$column_name = $column["name"];//set the column name

				$data_type = $column["type"];//set the column data type

				$length = $column["length"];//set the lenght of the data type

				if ($column["primary"])	$indices[] = "PRIMARY KEY ({$column_name})"; //add primary key field

				if ($column["index"]) $indices[] = "KEY {$column_name} ({$column_name})"; //add index field

				switch ($data_type)
				{
					case "autonumber":

						$lines[] = "{$column_name} INT(11) NOT NULL AUTO_INCREMENT";

						break;

					case "text":

						if ($length !== null && $length <= 255)	$lines[] = "{$column_name} VARCHAR({$length}) DEFAULT NULL";

						else $lines[] = "{$column_name} text";

						break;

					case "integer":

						$lines[] = "{$column_name} INT(11) DEFAULT NULL";

						break;

					case "decimal":

						$lines[] = "{$column_name} FLOAT DEFAULT NULL";

						break;

					case "boolean":

						$lines[] = "{$column_name} TINYINT(4) DEFAULT NULL";

						break;

					case "datetime":

						$lines[] = "{$column_name} DATETIME DEFAULT NULL";

						break;

				}

			}

			$this->query_string = sprintf($template, $this->table, join(",\n", $lines), join(",\n", $indices), 'InnoDB', 'utf8');//$this->connection->character_set_name()
			
			return $this;

		} catch (MySQLException $e) {

			$e->errorShow();

		}
		
	}
1107617
function mysqlDate (input) {
	var date = new Date(input.getTime());
	date.setMinutes(date.getMinutes() + date.getTimezoneOffset());

	var y = date.getFullYear();
	var m = ('0' + (date.getMonth() + 1)).substr(-2);
	var d = ('0' + date.getDate()).substr(-2);
	var h = ('0' + date.getHours()).substr(-2);
	var i = ('0' + date.getMinutes()).substr(-2);
	var s = ('0' + date.getSeconds()).substr(-2);

	return y + '-' + m + '-' + d + ' ' + h + ':' + i + ':' + s;
}
421944
public static void sqldayname(StringBuilder buf, List<? extends CharSequence> parsedArgs) throws SQLException {
    if (parsedArgs.size() != 1) {
      throw new PSQLException(GT.tr("{0} function takes one and only one argument.", "dayname"),
          PSQLState.SYNTAX_ERROR);
    }
    appendCall(buf, "to_char(", ",", ",'Day')", parsedArgs);
  }
837170
public function generateDays()
    {
        $interval = $this->startDate->diff($this->endDate);

        $day = clone $this->startDate;

        for ($i=0; $i<$interval->days+1; $i++)
        {
            if ($i)
            {
                $day->add(new \DateInterval('P1D'));
            }

            $this->days[] = array(
                'label' => $day->format($this->day_format),
                'class' => strtolower($day->format('l')),
            );
        }
    }
394949
public function buildCalendar( $cell_class = NULL, $heading_span = NULL )
	{
		$time	= mktime( 0, 0, 0, $this->getOption( 'show_month'), 1, $this->getOption( 'show_year' ) );
		$offset	= date( 'w', $time )-1;
		if( $offset < 0 )
			$offset += 7;
		$days	= date( "t", $time );
		$weeks	= ceil( ( $days + $offset ) / 7 );
		$d	= 1;
		$lines	= array();
		for( $w=0; $w<$weeks; $w++ )
		{
			$cells	= array();
			for( $i=0; $i<7; $i++ )
			{
				if( $offset )
				{
					$cells[]	= $this->buildCell( 0, $cell_class );
					$offset --;
				}
				else if( $d > $days )
					$cells[]	= $this->buildCell( 0, $cell_class );
				else
				{
					$cells[]	= $this->buildCell( $d, $cell_class );
					$d++;
				}
				$line	= implode( "", $cells );
			}
			$lines[]	= UI_HTML_Tag::create( "div", $line, array( 'class' => 'day-week' ) );
		}
		$lines		= implode( "\n\t  ", $lines );
		$days		= UI_HTML_Tag::create( "div", $lines, array( 'class' => "days" ) );
		$heading	= $this->buildHeading( $heading_span );
		$weekdays	= $this->buildWeekDays();
		$code		= $this->getCode( $heading, $weekdays, $days );
		return $code;
	}
55889
function genPassOfDay(d, s = DEFAULT_SEED) {
  if (!(d instanceof Date)) {
    throw new TypeError('Date is not a Date instance');
  }

  if (typeof s !== 'string') {
    throw new TypeError('Seed is not a String instance');
  }

  if (s.length < 1) {
    throw new Error('Seed min length: 1');
  }

  const seed = s.repeat(10);
  const year = d.getFullYear() % 100; // Two last digits
  const month = d.getMonth() + 1; // January === 1
  const dayOfMonth = d.getDate();
  const dayOfWeek = d.getDay() === 0 ? 6 : d.getDay() - 1; // Monday === 1

  const l1 = TABLE1[dayOfWeek].slice(0);
  l1.push(dayOfMonth);
  l1.push(year + month - dayOfMonth < 0
    ? (year + month - dayOfMonth + 36) % 36
    : (year + month - dayOfMonth) % 36);
  l1.push((3 + (year + month) % 12) * dayOfMonth % 37 % 36);

  const l2 = [...Array(8).keys()].map((_, i) => seed.charCodeAt(i) % 36);

  const l3 = l1.map((f, i) => (f + l2[i]) % 36);
  const l38 = l3.reduce((t, i) => t + i, 0) % 36;
  const num8 = l38 % 6;
  l3.push(l38);
  l3.push(Math.round(Math.pow(num8, 2)));

  const l4 = TABLE2[num8].map(i => l3[i]);

  const l5 = l4.map((v, i) => (seed.charCodeAt(i) + v) % 36);

  return l5.map(i => ALPHANUM[i]).join('');
}
657933
def build_table 
      <<-HTML.strip_heredoc.html_safe
        <div class='table-me'>
          #{table_filters}
          <div class="table-me-table #{'with-filters' if table_builder.filters}">
            #{table_pagination.pagination_info}
            <table>
              <thead>
                <tr>#{create_header}</tr>
              </thead>
              <tbody>
                #{table_rows}
              </tbody>
            </table>
            #{table_pagination.pagination_controls}
          </div>
        </div>
      HTML
    end
953090
function SQLDate($fmt, $col=false)
	{
	// use right() and replace() ?
		if (!$col) $col = $this->sysDate;

		/* use TO_CHAR() if $fmt is TO_CHAR() allowed fmt */
		if ($fmt== 'Y-m-d H:i:s')
			return 'TO_CHAR('.$col.", 'YYYY-MM-DD HH24:MI:SS')";

		$s = '';

		$len = strlen($fmt);
		for ($i=0; $i < $len; $i++) {
			if ($s) $s .= $this->concat_operator;
			$ch = $fmt[$i];
			switch($ch) {
			case 'Y':
			case 'y':
				if ($len==1) return "year($col)";
				$s .= "char(year($col))";
				break;
			case 'M':
				if ($len==1) return "monthname($col)";
				$s .= "substr(monthname($col),1,3)";
				break;
			case 'm':
				if ($len==1) return "month($col)";
				$s .= "right(digits(month($col)),2)";
				break;
			case 'D':
			case 'd':
				if ($len==1) return "day($col)";
				$s .= "right(digits(day($col)),2)";
				break;
			case 'H':
			case 'h':
				if ($len==1) return "hour($col)";
				if ($col != $this->sysDate) $s .= "right(digits(hour($col)),2)";
				else $s .= "''";
				break;
			case 'i':
			case 'I':
				if ($len==1) return "minute($col)";
				if ($col != $this->sysDate)
					$s .= "right(digits(minute($col)),2)";
					else $s .= "''";
				break;
			case 'S':
			case 's':
				if ($len==1) return "second($col)";
				if ($col != $this->sysDate)
					$s .= "right(digits(second($col)),2)";
				else $s .= "''";
				break;
			default:
				if ($ch == '\\') {
					$i++;
					$ch = substr($fmt,$i,1);
				}
				$s .= $this->qstr($ch);
			}
		}
		return $s;
	}
235029
function AddDay(Day $day)
    {
        foreach ($this->days as $currentDay)
        {
            if ($currentDay->DayOfWeek() == $day->DayOfWeek())
                return;
        }
        $this->days[] = $day;
    }
545741
private void populateCalendar(Record record, ProjectCalendar calendar, boolean isBaseCalendar)
   {
      if (isBaseCalendar == true)
      {
         calendar.setName(record.getString(0));
      }
      else
      {
         calendar.setParent(m_projectFile.getCalendarByName(record.getString(0)));
      }

      calendar.setWorkingDay(Day.SUNDAY, DayType.getInstance(record.getInteger(1)));
      calendar.setWorkingDay(Day.MONDAY, DayType.getInstance(record.getInteger(2)));
      calendar.setWorkingDay(Day.TUESDAY, DayType.getInstance(record.getInteger(3)));
      calendar.setWorkingDay(Day.WEDNESDAY, DayType.getInstance(record.getInteger(4)));
      calendar.setWorkingDay(Day.THURSDAY, DayType.getInstance(record.getInteger(5)));
      calendar.setWorkingDay(Day.FRIDAY, DayType.getInstance(record.getInteger(6)));
      calendar.setWorkingDay(Day.SATURDAY, DayType.getInstance(record.getInteger(7)));

      m_eventManager.fireCalendarReadEvent(calendar);
   }
779803
public void setDaysExcluded (final boolean [] days)
  {
    if (days == null)
    {
      throw new IllegalArgumentException ("The days parameter cannot be null.");
    }

    if (days.length < MAX_DAYS_IN_MONTH)
    {
      throw new IllegalArgumentException ("The days parameter must have a length of at least " +
                                          MAX_DAYS_IN_MONTH +
                                          " elements.");
    }

    m_aExcludeDays = days;
    m_aExcludeAll = areAllDaysExcluded ();
  }