private void DisplayDateDiff(StringBuilder html) { JewishDate now = new JewishDate(this._dailyZmanim.Location); int diffDays = this._displayingJewishDate.AbsoluteDate - now.AbsoluteDate; html.Append("<div class=\"padWidth\">"); if (diffDays == 0) { html.Append("היום"); } else if (diffDays == 1) { html.Append("מחר"); } else if (diffDays == 2) { html.Append("מחרתיים"); } else if (diffDays == -1) { html.Append("אתמול"); } else { int totalDays = Math.Abs(diffDays); if (diffDays < 0) { html.AppendFormat("לפני {0:N0} ימים", totalDays); } else { html.AppendFormat("בעוד {0:N0} ימים", totalDays); } if (totalDays > 29) { var dateDiff = new Itenso.TimePeriod.DateDiff( this._displayingJewishDate.GregorianDate, now.GregorianDate); int years = Math.Abs(dateDiff.ElapsedYears), months = Math.Abs(dateDiff.ElapsedMonths); if (years + months > 0) { int singleDays = Math.Abs(dateDiff.ElapsedDays); html.Append(" <span class=\"purpleoid seven italic\">"); if (years >= 1) { html.AppendFormat("{0:N0} {1}", years, years >= 2 ? "שנים" : "שנה"); } if (months >= 1) { html.AppendFormat(" {0:N0} {1}", months, (months >= 2 ? "חודשים" : "חודש")); } if (singleDays >= 1) { html.AppendFormat(" {0:N0} {1}", singleDays, (singleDays >= 2 ? "ימים" : "יום")); } html.Append("</span>"); } } } html.Append("</div>"); }
private void DisplayDateDiff(StringBuilder html) { JewishDate now = new JewishDate(this._dailyZmanim.Location); int diffDays = this._displayingJewishDate.AbsoluteDate - now.AbsoluteDate; html.Append("<div class=\"padWidth\">"); if (diffDays == 0) { html.Append("Today"); } else if (diffDays == 1) { html.Append("Tommorrow"); } else if (diffDays == -1) { html.Append("Yesterday"); } else { int totalDays = Math.Abs(diffDays); if (diffDays < 0) { html.AppendFormat("{0:N0} days ago", totalDays); } else { html.AppendFormat("In {0:N0} days", totalDays); } if (totalDays > 29) { var dateDiff = new Itenso.TimePeriod.DateDiff( this._displayingJewishDate.GregorianDate, now.GregorianDate); int years = Math.Abs(dateDiff.ElapsedYears), months = Math.Abs(dateDiff.ElapsedMonths); if (years + months > 0) { int singleDays = Math.Abs(dateDiff.ElapsedDays); html.Append(" <span class=\"purpleoid seven italic\">"); if (years >= 1) { html.AppendFormat("{0:N0} secular year{1}", years, years > 1 ? "s" : ""); } if (months >= 1) { html.AppendFormat(" {0:N0} secular month{1}", months, months > 1 ? "s" : ""); } if (singleDays >= 1) { html.AppendFormat(" {0:N0} day{1}", singleDays, singleDays > 1 ? "s" : ""); } html.Append("</span>"); } } } html.Append("</div>"); }