/*
 * Caudium - An extensible World Wide Web server
 * Copyright © 2000-2003 The Caudium Group
 * Copyright © 1994-2001 Roxen Internet Software
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

/* name="Czech language support for Roxen";
   doc="Author: Jan Petrous 16.10.1997<br>"
   "Based on Slovenian language module by Iztok Umek<br>"
   "E-mail: hop@unibase.cz<br>";

   You can do enything you want this code.
   Please consult me before modifying czech.pike.

   13.05.1998	hop	corrected one a little bug
			All texts are now in ISO 8859-2
   16.11.1998	hop	corrected name of months and days
             		(First letter must be lower case)

*/
string cvs_version = "$Id: czech.pike,v 1.3.4.3 2002/12/31 23:28:50 grendel Exp $";
string month(int num)
{
  return ({ "ledna", "února", "března", "dubna", "května",
	    "června", "července", "srpna", "září", "října",
	    "listopadu", "prosince" })[ num - 1 ];
}

string ordered(int i)
{
  switch(i)
  {
   case 0:
    return ("buggy");
   default:
      return (i+".");
  }
}

string date(int timestamp, mapping|void m)
{
  mapping t1=localtime(timestamp);
  mapping t2=localtime(time(0));

  if(!m) m=([]);

  if(!(m["full"] || m["date"] || m["time"]))
  {
    if(t1["yday"] == t2["yday"] && t1["year"] == t2["year"])
      return ("dnes, "+ ctime(timestamp)[11..15]);
  
    if(t1["yday"]+1 == t2["yday"] && t1["year"] == t2["year"])
      return ("včera, "+ ctime(timestamp)[11..15]);
  
    if((t1["yday"]-1) == t2["yday"] && t1["year"] == t2["year"])
      return ("zítra, "+ ctime(timestamp)[11..15]);
  
    if(t1["year"] != t2["year"])
      return (month(t1["mon"]+1) + " " + (t1["year"]+1900));
    return (ordered(t1["mday"]) + " " + month(t1["mon"]+1));
  }
  if(m["full"])
    return (ctime(timestamp)[11..15]+", "+
	   ordered(t1["mday"]) + " " + 
           month(t1["mon"]+1) + " " +
           (t1["year"]+1900));
  if(m["date"])
    return (ordered(t1["mday"]) + " " + month(t1["mon"]+1) + " " +
       (t1["year"]+1900));
  if(m["time"])
    return (ctime(timestamp)[11..15]);
}


string number(int num)
{
  if(num<0)
    return ("minus "+number(-num));
  switch(num)
  {
   case 0:  return ("");
   case 1:  return ("jedna");
   case 2:  return ("dvě");
   case 3:  return ("tři");
   case 4:  return ("čtyři");
   case 5:  return ("pět");
   case 6:  return ("±est");
   case 7:  return ("sedm");
   case 8:  return ("osm");
   case 9:  return ("devět");
   case 10: return ("deset");
   case 11: return ("jedenáct");
   case 12: return ("dvanáct");
   case 13: case 16..18: return (number(num-10)+"náct");
   case 14: return ("čtrnáct");
   case 15: return ("patnást");
   case 19: return ("devatenáct");
   case 20: return ("dvacet");
   case 30: return ("třicet");
   case 40: return ("čtyřicet");
   case 50: return ("padesát");
   case 60: return ("±edesát");
   case 70: return ("sedmdesát");
   case 80: return ("osmdesát");
   case 90: return ("devadesát");
   case 21..29: case 31..39: 
   case 51..59: case 61..69: case 71..79: 
   case 81..89: case 91..99: case 41..49: 
     return (number((num/10)*10)+number(num%10));
   case 100..199: return ("sto"+number(num%100));
   case 200..299: return ("dvěstě "+number(num%100));
   case 300..499: return (number(num/100)+"sta "+number(num%100));
   case 500..999: return (number(num/100)+"set "+number(num%100));
   case 1000..1999: return ("tisíc "+number(num%1000));
   case 2000..2999: return ("dva tisíce "+number(num%1000));
   case 3000..999999: return (number(num/1000)+" tisíc "+number(num%1000));
   case 1000000..999999999: 
     return (number(num/1000000)+" milion "+number(num%1000000));
   default:
    perror("foo\n"+ num +"\n");
    return ("hodně");
  }
}

string day(int num)
{
  return ({ "neděle","pondělí","úterý","středa",
	    "čtvrtek","pátek","sobota" })[ num - 1 ];
}

array aliases()
{
  return ({ "cs", "cz", "cze", "czech" });
}



