C # Calculate the time difference between the input time and today,
/// <Summary>
/// Calculate the time difference between the input time and the current day
/// </Summary>
/// <Param name = "dt"> </param>
/// <Param name = "yy"> </param>
/// <Param name = "mm"> </param>
/// <Param name = "dd"> </param>
Public void GetCriminalYX (DateTime dt, out int yy, out int mm, out int dd)
{
DateTime now = DateTime. Now;
Yy = mm = dd = 0;
If (dt. Year> 9000 | dt. Year = 1900)
{
Return;
}
If (dt <= now)
{
Return;
}
StringBuilder str = new StringBuilder ();
Int dt_Y = dt. Year;
Int dt_M = dt. Month;
Int dt_D = dt. Day;
Int now_Y = DateTime. Now. Year;
Int now_M = DateTime. Now. Month;
Int now_D = DateTime. Now. Day;
Yy = dt_Y-now_Y;
Mm = dt_M-now_M;
Dd = 0;
Int dt_M_SY = 0;
If (dt_D <now_D)
{
Mm-= 1;
Dt_M_SY = dt_M-1;
If (dt_M_SY = 0)
{
Dt_M_SY = 12;
}
If (dt_M_SY = 2)
{
Dt_M_SY = dt_Y % 4 = 0? 29: 28;
}
Else
{
Dt_M_SY = 2 | dt_M_SY = 4 | dt_M_SY = 6 | dt_M_SY = 9 | dt_M_SY = 11? 30: 31;
}
Dt_D + = dt_M_SY;
}
Dd = dt_D-now_D;
If (mm <0)
{
Yy-= 1;
Mm + = 12;
}
}