Feature: New Theme
New icon, theme, and fuzzy time. Add moment.js
This commit is contained in:
@@ -23,117 +23,6 @@ namespace Disco.BI.Extensions
|
||||
}
|
||||
}
|
||||
|
||||
#region Date/Time Extensions
|
||||
public static string ToFuzzy(this DateTime d)
|
||||
{
|
||||
var n = DateTime.Now;
|
||||
|
||||
// Today
|
||||
if (d.Date == n.Date)
|
||||
{
|
||||
if (d < n)
|
||||
{
|
||||
// Earlier
|
||||
if (d > n.AddMinutes(-1))
|
||||
return "A moment ago";
|
||||
|
||||
if (d > n.AddMinutes(-10))
|
||||
return "A few minutes ago";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Later
|
||||
if (d < n.AddMinutes(1))
|
||||
return "In a moment";
|
||||
|
||||
if (d < n.AddMinutes(10))
|
||||
return "In a few minutes";
|
||||
}
|
||||
|
||||
return string.Format("Today at {0:h:mm tt}", d);
|
||||
}
|
||||
|
||||
if (d.Date < n.Date)
|
||||
{
|
||||
// PAST
|
||||
var dif = n.Subtract(d);
|
||||
|
||||
// Yesterday
|
||||
if (d.Date == n.Date.AddDays(-1))
|
||||
return string.Format("Yesterday at {0:h:mm tt}", d);
|
||||
// Last Week
|
||||
if (dif.TotalDays <= 7)
|
||||
return string.Format("Last {0:dddd} at {0:h:mm tt}", d);
|
||||
// Within 8 Weeks
|
||||
if (d > n.Date.AddMonths(-2))
|
||||
return string.Format("{0} Weeks ago, {1:ddd, d MMM}", (int)(dif.TotalDays / 7), d);
|
||||
// Same Year
|
||||
if (d.Year == n.Year)
|
||||
return string.Format("{0} Months ago, {1:ddd, d MMM}", (int)(dif.TotalDays / 30), d);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Future
|
||||
var dif = d.Subtract(n);
|
||||
|
||||
// Tomorrow
|
||||
if (d.Date == n.Date.AddDays(1))
|
||||
return string.Format("Tomorrow at {0:h:mm tt}", d);
|
||||
// Next Week
|
||||
if (dif.TotalDays <= 7)
|
||||
return string.Format("Next {0:dddd} at {0:h:mm tt}", d);
|
||||
// < 2 Month
|
||||
if (d < n.Date.AddMonths(2))
|
||||
return string.Format("In {0} Weeks, {1:ddd, d MMM}", (int)(dif.TotalDays / 7), d);
|
||||
// Same Year
|
||||
if (d.Year == n.Year)
|
||||
return string.Format("In {0} Months, {1:ddd, d MMM}", (int)(dif.TotalDays / 30), d);
|
||||
}
|
||||
|
||||
return d.ToString("ddd, d MMM yyyy");
|
||||
}
|
||||
public static string ToFuzzy(this DateTime? d, string NullValue = "N/A")
|
||||
{
|
||||
if (d.HasValue)
|
||||
return ToFuzzy(d.Value);
|
||||
else
|
||||
return NullValue;
|
||||
}
|
||||
public static string ToFullDateTime(this DateTime d)
|
||||
{
|
||||
return d.ToString("ddd, d MMM yyyy @ h:mm:sstt");
|
||||
}
|
||||
public static string ToFullDateTime(this DateTime? d, string NullValue = "N/A")
|
||||
{
|
||||
if (d.HasValue)
|
||||
return ToFullDateTime(d.Value);
|
||||
else
|
||||
return NullValue;
|
||||
}
|
||||
public static long ToSortableDateTime(this DateTime? d)
|
||||
{
|
||||
if (d.HasValue)
|
||||
return d.Value.ToBinary();
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
public static long ToSortableDateTime(this DateTime d)
|
||||
{
|
||||
return d.ToBinary();
|
||||
}
|
||||
public static string ToJavascriptDateTime(this DateTime d)
|
||||
{
|
||||
return d.ToString("yyyy/MM/dd hh:mm tt");
|
||||
}
|
||||
public static string ToJavascriptDateTime(this DateTime? d)
|
||||
{
|
||||
if (d.HasValue)
|
||||
return d.Value.ToString("yyyy/MM/dd hh:mm tt");
|
||||
else
|
||||
return null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Image Extensions
|
||||
|
||||
public static Bitmap RotateImage(this Image Source, float Angle, Brush BackgroundColor = null, bool ResizeIfOver45Deg = true)
|
||||
|
||||
Reference in New Issue
Block a user