<?php

class Layout extends mfLayout {
  protected static $instance;
  
  
  public static function singleton($param=false) {
		if(!isset(self::$instance)) {
			$c=__CLASS__;
			self::$instance=new $c($param);
		}
		return self::$instance;
	}

  public static function dotToComma($num) {
    return str_replace(".", ",", $num);
  }
  
  public static function commaToDot($num) {
    return str_replace(",", ".", $num);
  }
  
  public static function dateToInt($date) {
    if(!preg_match('/^(\d\d)\.(\d\d)\.(\d\d\d\d)$/',$date, $m)) {
      return false;
    } else {
      $day = intval($m[1]);
      $month = intval($m[2]);
      $year = intval($m[3]);

      if($day > 31 || $day < 1
        || $month > 12 || $month < 1)
      {
        return false;
      }
      
      $date_ts = mktime(0,0,0,$month,$day,$year);
      return $date_ts;
    }
  }
  
  public static function intToDate($int) {
    return date("d.m.Y", $int);
  }
}
