Guest User

Untitled

a guest
Jun 14th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName (DateTime.Now.Month);
  2.  
  3. DateTime dt = DateTime.Parse("12 January 2009";
  4. dt.ToString("MMM"); // prints "Jan"
  5. // (or the right abbrev is in current culture)
  6. dt.ToString("MMMM"); // prints "January"
  7. // (or correct sp in current culture)
  8.  
  9. Microsoft.VisualBasic.MonthName
  10.  
  11. Thread.CurrentThread.CurrentCulture.DateTimeFormat.GetMonthName
  12.  
  13. if (DateTime.Now.Month != 1) // can't run this test in January.
  14.  
  15. if (DateTime.Now.Month != DateTime.MonthsOfYear.January)
  16.  
  17. Public Enum MonthsOfYear
  18. January = 1
  19. February = 2
  20. March = 3
  21. April = 4
  22. May = 5
  23. June = 6
  24. July = 7
  25. August = 8
  26. September = 9
  27. October = 10
  28. November = 11
  29. December = 12
  30. End Enum
  31.  
  32. List<string> monthNames = DateTimeFormatInfo.CurrentInfo.MonthNames.Take(12).ToList();
  33. var monthSelectList = monthNames.Select(
  34. m => new { Id = monthNames.IndexOf(m) + 1, Name = m });
  35.  
  36. public enum Month
  37. {
  38. NotSet = 0,
  39. January = 1,
  40. February = 2,
  41. March = 3,
  42. April = 4,
  43. May = 5,
  44. June = 6,
  45. July = 7,
  46. August = 8,
  47. September = 9,
  48. October = 10,
  49. November = 11,
  50. December = 12
  51. }
Add Comment
Please, Sign In to add comment