using System.Collections.Generic;
DateTime a = DateTime.Now.AddHours(1);
DateTime b = DateTime.Now.AddMinutes(120);
string c = DateDiff(a, b);
Console.WriteLine(49.ToString("X"));
Console.WriteLine(ErrorNumToCode("1"));
int TimeHour = int.Parse(DateTime.Now.ToString("HH"));
Console.WriteLine(TimeHour);
long TimeHour2 = long.Parse(DateTime.Now.ToString("yyyyMMddHHmmss"));
Console.WriteLine(TimeHour2);
public string DateDiff(DateTime DateTime1, DateTime DateTime2) {
TimeSpan ts1 = new TimeSpan(DateTime1.Ticks);
TimeSpan ts2 = new TimeSpan(DateTime2.Ticks);
TimeSpan ts = ts1.Subtract(ts2).Duration();
dateDiff = ts.TotalMinutes.ToString();
public string ErrorNumToCode(string Number) {
if (Number.Length == 4) {
strReturn = int.Parse(Number).ToString("X");
List<KeyValuePair<string, int>> kvpList = new List<KeyValuePair<string, int>>()
new KeyValuePair<string, int>("A", 0),
new KeyValuePair<string, int>("C", 1),
new KeyValuePair<string, int>("E", 2),
new KeyValuePair<string, int>("F", 3),
new KeyValuePair<string, int>("H", 4),
new KeyValuePair<string, int>("J", 5),
new KeyValuePair<string, int>("L", 6),
new KeyValuePair<string, int>("P", 7),
int intCode = int.Parse(Number) / 32;
strReturn = kvpList.Where(x => x.Value == intCode).Select(x => x.Key).FirstOrDefault();
strReturn += (int.Parse(Number) - (intCode * 32)).ToString().PadLeft(2, '0');