Skip to content

Date.Formating - 0.8 #256

Open
Open
@andrewharry

Description

@andrewharry

I am struggling to get the string.format to work with date formats

I have stepped through the code and it appears that the constructor for my date object doesn't have a 'name' field
and the constructor has a prototype called 'invalid date'

The date has been passed in by json from my server. I transform this into a javascript date object with the code below

        internal static Date FixDate(Date date) {
            if (Script.IsNullOrUndefined(date)) return null;
            if (date.ToString().IndexOf("Date") > -1)
                return new Date(int.Parse(date.ToString().Substr(6)));
            return date;
        }

And I am using the next piece for formatting the date

        internal static int ToYearMonthKey(Date date) {
            if (Script.IsNullOrUndefined(date)) return 0;
            return int.Parse(string.Format(CultureInfo.InvariantCulture, "{0:yyyyMM}", date));
        }

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions