namespace DateTimeLibrary
{
using System;
using System.Collections;
public class DateTimeLibrary
{
public static string FirstDayOfCurrentMonth()
{
DateTime today = DateTime.Today;
DateTime time2 = new DateTime(today.Year, today.Month, 1);
return time2.ToShortDateString();
}
public static string FirstDayOfCurrenttQuarter()
{
DateTime time2;
DateTime time3;
DateTime today = DateTime.Today;
int num = int.Parse(today.Month.ToString());
if (num != 0)
{
int num2 = (num % 3) - 1;
time3 = today.AddMonths(-num2);
time2 = new DateTime(time3.Year, time3.Month, 1);
}
else
{
time3 = today.AddMonths(-2);
time2 = new DateTime(time3.Year, time3.Month, 1);
}
return time2.ToShortDateString();
}
public static string FirstDayOfCurrenttWeek()
{
DateTime today = DateTime.Today;
DateTime time2 = new DateTime(today.Year, today.Month, today.Day);
Hashtable hashtable = new Hashtable();
hashtable["Monday"] = "0";
hashtable["Tuesday"] = "1";
hashtable["Wednesday"] = "2";
hashtable["Thursday"] = "3";
hashtable["Friday"] = "4";
hashtable["Saturday"] = "5";
hashtable["Sunday"] = "6";
string s = (string) hashtable[today.DayOfWeek.ToString()];
int num = int.Parse(s);
return time2.AddDays((double) -num).ToShortDateString();
}
public static string FirstDayOfCurrentYear()
{
DateTime today = DateTime.Today;
DateTime time2 = new DateTime(today.Year, 1, 1);
return time2.ToShortDateString();
}
public static string FirstDayOfLastMonth()
{
DateTime today = DateTime.Today;
DateTime time2 = new DateTime(today.Year, today.Month - 1, 1);
return time2.ToShortDateString();
}
public static string FirstDayOfLastQuarter()
{
DateTime time2;
DateTime time3;
DateTime today = DateTime.Today;
int num = int.Parse(today.Month.ToString());
if (num != 0)
{
int num2 = (num % 3) - 1;
time3 = today.AddMonths(-(num2 + 3));
time2 = new DateTime(time3.Year, time3.Month, 1);
}
else
{
time3 = today.AddMonths(-5);
time2 = new DateTime(time3.Year, time3.Month, 1);
}
return time2.ToShortDateString();
}
public static string FirstDayOfLastWeek()
{
DateTime today = DateTime.Today;
DateTime time2 = new DateTime(today.Year, today.Month, today.Day);
Hashtable hashtable = new Hashtable();
hashtable["Monday"] = "0";
hashtable["Tuesday"] = "1";
hashtable["Wednesday"] = "2";
hashtable["Thursday"] = "3";
hashtable["Friday"] = "4";
hashtable["Saturday"] = "5";
hashtable["Sunday"] = "6";
string s = (string) hashtable[today.DayOfWeek.ToString()];
int num = int.Parse(s) + 7;
return time2.AddDays((double) -num).ToShortDateString();
}
public static string FirstDayOfLastYear()
{
DateTime today = DateTime.Today;
DateTime time2 = new DateTime(today.Year - 1, 1, 1);
return time2.ToShortDateString();
}
public static string FirstDayOfNextMonth()
{
DateTime today = DateTime.Today;
DateTime time2 = new DateTime(today.Year, today.Month + 1, 1);
return time2.ToShortDateString();
}
public static string FirstDayOfNextQuarter()
{
DateTime time3;
DateTime today = DateTime.Today;
int num = int.Parse(today.Month.ToString());
if (num != 0)
{
int month = num + (3 - (num % 3));
DateTime time2 = new DateTime(today.Year, month, 1);
time3 = time2.AddMonths(1);
}
else
{
time3 = new DateTime(today.Year, today.Month, 1).AddMonths(1);
}
return time3.ToShortDateString();
}
public static string FirstDayOfNextWeek()
{
DateTime today = DateTime.Today;
DateTime time2 = new DateTime(today.Year, today.Month, today.Day);
Hashtable hashtable = new Hashtable();
hashtable["Monday"] = "0";
hashtable["Tuesday"] = "1";
hashtable["Wednesday"] = "2";
hashtable["Thursday"] = "3";
hashtable["Friday"] = "4";
hashtable["Saturday"] = "5";
hashtable["Sunday"] = "6";
string s = (string) hashtable[today.DayOfWeek.ToString()];
int num = int.Parse(s);
return time2.AddDays((double) (-num + 7)).ToShortDateString();
}
public static string FirstDayOfNextYear()
{
DateTime today = DateTime.Today;
DateTime time2 = new DateTime(today.Year + 1, 1, 1);
return time2.ToShortDateString();
}
public static string LastDayOfCurrentMonth()
{
DateTime today = DateTime.Today;
DateTime time2 = new DateTime(today.Year, today.Month + 1, 1);
return time2.AddDays(-1.0).ToShortDateString();
}
public static string LastDayOfCurrenttQuarter()
{
DateTime time2;
DateTime time3;
DateTime today = DateTime.Today;
int num = int.Parse(today.Month.ToString());
if (num != 0)
{
int month = num + (3 - (num % 3));
time2 = new DateTime(today.Year, month, 1);
time2.AddMonths(1);
time2.AddDays(-1.0);
time3 = time2.AddMonths(1).AddDays(-1.0);
}
else
{
time2 = new DateTime(today.Year, today.Month, 1);
time2.AddMonths(1);
time2.AddDays(-1.0);
time3 = time2.AddMonths(1).AddDays(-1.0);
}
return time3.ToShortDateString();
}
public static string LastDayOfCurrentWeek()
{
DateTime today = DateTime.Today;
DateTime time2 = new DateTime(today.Year, today.Month, today.Day);
Hashtable hashtable = new Hashtable();
hashtable["Monday"] = "0";
hashtable["Tuesday"] = "1";
hashtable["Wednesday"] = "2";
hashtable["Thursday"] = "3";
hashtable["Friday"] = "4";
hashtable["Saturday"] = "5";
hashtable["Sunday"] = "6";
string s = (string) hashtable[today.DayOfWeek.ToString()];
int num = int.Parse(s) + 1;
return time2.AddDays((double) (-num + 7)).ToShortDateString();
}
public static string LastDayOfCurrentYear()
{
DateTime today = DateTime.Today;
DateTime time2 = new DateTime(today.Year, 12, 0x1f);
return time2.ToShortDateString();
}
public static string LastDayOfLastMonth()
{
DateTime today = DateTime.Today;
DateTime time2 = new DateTime(today.Year, today.Month - 1, 1);
return time2.AddMonths(1).AddDays(-1.0).ToShortDateString();
}
public static string LastDayOfLastQuarter()
{
DateTime time2;
DateTime time3;
DateTime today = DateTime.Today;
int num = int.Parse(today.Month.ToString());
if (num != 0)
{
int month = num + (3 - (num % 3));
time2 = new DateTime(today.Year, month, 1);
time3 = time2.AddMonths(1).AddDays(-1.0).AddMonths(-3);
}
else
{
time2 = new DateTime(today.Year, today.Month, 1);
time3 = time2.AddMonths(1).AddDays(-1.0).AddMonths(-3);
}
return time3.ToShortDateString();
}
public static string LastDayOfLastYear()
{
DateTime today = DateTime.Today;
DateTime time2 = new DateTime(today.Year - 1, 12, 0x1f);
return time2.ToShortDateString();
}
public static string LastDayOfNextMonth()
{
DateTime today = DateTime.Today;
DateTime time2 = new DateTime(today.Year, today.Month + 2, 1);
return time2.AddDays(-1.0).ToShortDateString();
}
public static string LastDayOfNextQuarter()
{
DateTime time2;
DateTime time3;
DateTime today = DateTime.Today;
int num = int.Parse(today.Month.ToString());
if (num != 0)
{
int month = num + (3 - (num % 3));
time2 = new DateTime(today.Year, month, 1);
time3 = time2.AddMonths(1).AddMonths(3).AddDays(-1.0);
}
else
{
time2 = new DateTime(today.Year, today.Month, 1);
time3 = time2.AddMonths(1).AddMonths(3).AddDays(-1.0);
}
return time3.ToShortDateString();
}
public static string LastDayOfNextWeek()
{
DateTime today = DateTime.Today;
DateTime time2 = new DateTime(today.Year, today.Month, today.Day);
Hashtable hashtable = new Hashtable();
hashtable["Monday"] = "0";
hashtable["Tuesday"] = "1";
hashtable["Wednesday"] = "2";
hashtable["Thursday"] = "3";
hashtable["Friday"] = "4";
hashtable["Saturday"] = "5";
hashtable["Sunday"] = "6";
string s = (string) hashtable[today.DayOfWeek.ToString()];
int num = int.Parse(s) + 1;
return time2.AddDays((double) (-num + 14)).ToShortDateString();
}
public static string LastDayOfNextYear()
{
DateTime today = DateTime.Today;
DateTime time2 = new DateTime(today.Year + 1, 12, 0x1f);
return time2.ToShortDateString();
}
public static string LastOfLastWeek()
{
DateTime today = DateTime.Today;
DateTime time2 = new DateTime(today.Year, today.Month, today.Day);
Hashtable hashtable = new Hashtable();
hashtable["Monday"] = "0";
hashtable["Tuesday"] = "1";
hashtable["Wednesday"] = "2";
hashtable["Thursday"] = "3";
hashtable["Friday"] = "4";
hashtable["Saturday"] = "5";
hashtable["Sunday"] = "6";
string s = (string) hashtable[today.DayOfWeek.ToString()];
int num = int.Parse(s) + 1;
return time2.AddDays((double) -num).ToShortDateString();
}
}
}
닷넷이란 무엇일까요? (1) | 2009.04.20 |
---|---|
C# - CookieHelper 만들기 (1) | 2009.04.14 |
객체 정보를 얻기위해 Reflection 을 사용해 보자 (0) | 2009.03.10 |
C# ENUM 키워드의 Description 를 이용하여 값을 가져오기 (6) | 2009.03.10 |
Generic Array 을 유용하게 사용해 보자 (2) | 2009.03.10 |