10

Get a DateTime. Convert to a string. Convert back to a DateTime. Use that DateTime to build a string.

WHY.

(it's red because I refactored it; snipped copied from our version control)

Comments
  • 0
    The only reason I see is that they were trying to get it to only have monthly precision. Hence, first day of the month being the name of the variable
  • 1
    @iam13islucky Yeah, I'm pretty sure it's just some previous messy refactor or something. I could look into the version control history but I don't know if I care that much. But it's just... very silly.
  • 1
    Ok, I looked into the history because who doesn't love a good mystery? It's the handiwork of the coworker I suspected. The Description of the checkin is "make calendar month name work with xAxis"

    var rawValue = record.GetAttributeValue<DateTime>(_calendarDataTimeAttribute);
    - var dateFirstDayOfMonth = new DateTime(rawValue.Year, rawValue.Month, 1);
    + var rawValue = record.GetAttributeValue<DateTime>(_calendarDataTimeAttribute);
    + var rawDate = rawValue.ToString("MMMM-yyyy");
    + var dateFirstDayOfMonth = Convert.ToDateTime(rawDate);
    + return new ValueResult(record, record, dateFirstDayOfMonth.ToMonthName() + " " + dateFirstDayOfMonth.Year).AsList();
Add Comment