You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
762 B
26 lines
762 B
using System;
|
|
using System.Globalization;
|
|
|
|
namespace ChangkeTec.Utils
|
|
{
|
|
public static class DateTimeHelper
|
|
{
|
|
public static int GetWeekOfYear(DateTime date)
|
|
{
|
|
var gc = new GregorianCalendar();
|
|
var weekOfYear = gc.GetWeekOfYear(date, CalendarWeekRule.FirstDay, DayOfWeek.Monday);
|
|
return weekOfYear;
|
|
}
|
|
|
|
public static DateTime GetTimeFromString(string strTime, string format)
|
|
{
|
|
IFormatProvider cnProvider = new CultureInfo("zh-CN", true);
|
|
|
|
if (strTime.Contains("."))
|
|
{
|
|
strTime = strTime.Replace(".", "-");
|
|
}
|
|
return DateTime.ParseExact(strTime, format, cnProvider, DateTimeStyles.None);
|
|
}
|
|
}
|
|
}
|