<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */

class DateParams extends Parameters
{
  public static function getInstance($dboperation)
  {
    static $instance = null;
    if (is_null($instance)) {
      $instance = new DateParams();
    }

    return $instance;
  }

  public function is_valid_type($value)
  {
    return $value == DEFAULTDATE
        || $value == DEFAULTDATE . ' ' . DEFAULTTIME
        || $value == DEFAULTDATE . ' ' . DEFAULTTIME_WITH_SECONDS
        || DateTimeOperations::isValidDate($value)
        || DateTimeOperations::isValidDateTime($value, DateTimeOperations::DATETIME_FORMAT_FULL)
        || DateTimeOperations::isValidDateTime($value);
  }

  public function prepare_value($value, $dboperation)
  {
    $datetimeop = new DateTimeOperations($dboperation->getDBName());

    return $datetimeop->getFormatDate4Server($value);
  }
}