using System;
using System.Web;
using System.Text;
using System.Text.RegularExpressions;
namespace DC
{
class DateConvertor
{
private static DateConvertor m_DateConvert = null;
private char[] strChinese;
private DateConvertor()
{
strChinese = new char[] {
'〇','一','二','三','四','五','六','七','八','九','十'
};
}
public static DateConvertor Instance
{
get
{
if (m_DateConvert == null)
m_DateConvert = new DateConvertor();
return m_DateConvert;
}
}
public string ToChineseYear(int year)
{
StringBuilder result = new StringBuilder();
string sYear = year.ToString();
foreach (Char c in sYear)
{
int i = 0;
int.TryParse(c.ToString(), out i);
result.Append(strChinese[i]);
}
return result.ToString();
}
public string ToChineseDayOrMonth(int day)
{
StringBuilder result = new StringBuilder();
string sDay = day.ToString();
for (int i = 0; i < sDay.Length; ++i )
{
char c = sDay[i];
int tmp = 0;
int.TryParse(c.ToString(), out tmp);
if (sDay.Length == 1) {
result.Append(strChinese[tmp]);
}
else if (sDay.Length == 2) {
if (i == 0)
{
if (tmp > 1)
result.Append(strChinese[tmp]);
result.Append("十");
}
else if (i == 1)
{
if (tmp > 0)
result.Append(strChinese[tmp]);
}
}
}
return result.ToString();
}
}
}