Get Formatted Day - CSharp System

CSharp examples for System:Math Number

Description

Get Formatted Day

Demo Code


using System;//from   www . java  2s.  c  o  m

public class Main{
        public static string GetFormattedDay(DateTimeOffset date)
      {
         string toReturn = null;

         var days = (date.Day - DateTimeOffset.Now.Day);

         if (days == 0) {
            toReturn = "today";   
         } else if (days == 1) {
            toReturn = "tomorrow";
         } else {
            toReturn = string.Format ("{0:MM/dd}", date);
         }

         return toReturn;
      }
}

Related Tutorials