Skip to content

Instantly share code, notes, and snippets.

@TheDarkCode
Created January 5, 2019 22:23
Show Gist options
  • Save TheDarkCode/4798e00ba2a114e4a08dafa01da9415a to your computer and use it in GitHub Desktop.
Save TheDarkCode/4798e00ba2a114e4a08dafa01da9415a to your computer and use it in GitHub Desktop.
QClock Conversion Extensions
using System;
using System.Collections.Generic;
using System.Text;
namespace QClockExtensions
{
public static class DateExtensions
{
public static int ToQClockMinute(this DateTime date)
{
DateTime zeroDate = new DateTime(2017, 10, 8);
if (date.Year == zeroDate.Year && date.Month == zeroDate.Month && date.Day == zeroDate.Day)
{
return 0;
}
int days = (date - zeroDate).Days;
if (date < zeroDate)
{
return (days % 60) + 60;
}
else
{
return (days % 60);
}
}
}
public static class IntExtensions
{
public static int QClockToMirror(this int minute)
{
if (minute > 60 || minute < 0)
{
// Invalid Entry
return 0;
}
return minute >= 30 ? minute - 30 : minute + 30;
}
public static int QClockToFlip(this int minute)
{
if (minute > 60 || minute < 0)
{
// Invalid Entry
return 0;
}
return minute <= 50 ? Math.Abs(minute-50) : 60 - Math.Abs(minute-50);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment