WIP
This commit is contained in:
@@ -16,13 +16,32 @@ namespace Church.Net.Utility
|
||||
int daysToAdd = ((int)day - (int)start.DayOfWeek + 7) % 7;
|
||||
return start.AddDays(daysToAdd);
|
||||
}
|
||||
public static DateTime Now()
|
||||
public static DateTime Now(string timeZoneCode=null)
|
||||
{
|
||||
TimeZoneInfo timeZone;
|
||||
if (null== timeZoneCode)
|
||||
{
|
||||
timeZone = pacificZone;
|
||||
}
|
||||
else
|
||||
{
|
||||
timeZone = TimeZoneInfo.FindSystemTimeZoneById(timeZoneCode);
|
||||
}
|
||||
return TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, pacificZone);
|
||||
}
|
||||
public static DateTime Today()
|
||||
public static DateTime Today(string timeZoneCode = null)
|
||||
{
|
||||
return Now().Date;
|
||||
return Now(timeZoneCode).Date;
|
||||
}
|
||||
public static DateTime ToUtc(this DateTime time,string timeZoneCode)
|
||||
{
|
||||
TimeZoneInfo timeZone = TimeZoneInfo.FindSystemTimeZoneById(timeZoneCode);
|
||||
return TimeZoneInfo.ConvertTimeToUtc(time, timeZone);
|
||||
}
|
||||
public static DateTime ToLocal(this DateTime time, string timeZoneCode)
|
||||
{
|
||||
TimeZoneInfo timeZone = TimeZoneInfo.FindSystemTimeZoneById(timeZoneCode);
|
||||
return TimeZoneInfo.ConvertTimeFromUtc(time, timeZone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,9 @@ namespace Church.Net.Utility
|
||||
{
|
||||
byte[] data = Convert.FromBase64String(token);
|
||||
DateTime when = DateTime.FromBinary(BitConverter.ToInt64(data, 0));
|
||||
#if DEBUG
|
||||
when = DateTime.Today.AddDays(1);
|
||||
#endif
|
||||
if (when >= DateTime.Now)
|
||||
{
|
||||
string userId = Encoding.ASCII.GetString(data.Skip(8).ToArray());
|
||||
|
||||
Reference in New Issue
Block a user