Skip to content

Can't control DateTime representations in Example #258

@masters3d

Description

@masters3d

code:

    class Options
    {
        [Option("startDate", Required = true, HelpText = "The start of the date range. yyyy-mm-dd")]
        public DateTime StartDate { get; set; }

        [Option("endDate", Required = true, HelpText = "The end of the date range. yyyy-mm-dd")]
        public DateTime EndDate { get; set; }

        [Usage(ApplicationAlias = "myExe")]
        public static IEnumerable<Example> Examples
        {
            get
            {
                var dateA = DateTime.Now.AddDays(-7);
                var dateB = DateTime.Now;
                yield return new Example("Normal scenario", new Options { StartDate = dateA, EndDate = dateB });
            }
        }
     }

command line:

Normal scenario:
myExe --endDate 3/20/2018 11:46:56 AM --startDate 3/13/2018 11:46:56 AM

desired:
myExe --endDate 2018-03-20 --startDate 2018-03-18

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions