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


class DateTimeOperationsMSSQL extends DateTimeOperationsServer
{
  
  public function getDateStr($datetimevalue)
  {
    if ($datetimevalue == null) {
      return DEFAULTDATE;
    }

    $month = StringOperations::substr($datetimevalue, 5, 2);

    
    return StringOperations::substr($datetimevalue, 8, 2) . '.' . $month . '.' . StringOperations::substr($datetimevalue, 0, 4);

    
  }

  

  
  public function getShortDateStr($datetimevalue)
  {
    $tmp = DateTimeOperationsMSSQL::getDateStr($datetimevalue);

    return StringOperations::substr($tmp, 0, 6);
  }

  
  public function getFormatDate4Server($day, $month, $year)
  {
    return "'" . $day . '.' . $month . '.' . $year . "'";
  }

  
  
  
  public function getFormatTime4Server($minute, $hour, $day = 30, $month = 12, $year = 1899, $second = 0)
  {
    if ($minute == '') {
      $minute = '0';
    }
    if ($hour == '') {
      $hour = '0';
    }
    $secondPart = '';
    if ($second != 0) {
      $secondPart = ':' . $second;
    }

    return "convert(datetime,'$year-$month-$day $hour:{$minute}{$secondPart}',20)";
  }
}