Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to create a Time parameter

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to create a Time parameter

    I am using NT8 RC1. I want a parameter that is only a time of day, not a complete DateTime. I created a new strategy using the Strategy Wizard and I specific "Time" as my parameter type. It created this code:
    Code:
            PreSessionStart                        = DateTime.Parse("9:00 AM");
    
            [NinjaScriptProperty]
            [Display(ResourceType = typeof(Custom.Resource), Name="PreSessionStart", Description="Opening time of pre-session", Order=1, GroupName="NinjaScriptStrategyParameters")]
            public DateTime PreSessionStart
            { get; set; }
    But in the strategy properties panel, the parameter looks like this:

    PreSessionStart 09/03/2016

    ...with a calendar widget to pick a date. How do I change this parameter definition so it will only accept a valid time value? I tried messing with the get/set code, but really screwed up NT8 to where it would not even open up the Strategies window! :-)

    Thanks!
    Bryan

    #2
    Hello Bryan,

    Thank you for your post.

    I will report this to development.

    To create a time parameter like you wish you can use TimeSpan. For example:
    • In OnStateChange() when checking SetDefaults:

    Code:
    		MyTime						= new TimeSpan(8,0,0);
    • In the Properties region of the code:

    Code:
    		[NinjaScriptProperty]
    		[Display(ResourceType = typeof(Custom.Resource), Name="MyTime", Description="MyTime", Order=1, GroupName="NinjaScriptStrategyParameters")]
    		public TimeSpan MyTime
    		{ get; set; }

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    574 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    332 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    553 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    551 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X