File tree Expand file tree Collapse file tree
example/BlazorLocalTimeSample/Pages Expand file tree Collapse file tree Original file line number Diff line number Diff line change 147147 </LocalTimeForm >
148148</div >
149149
150+ <p >
151+ If you want to use non-nullable components or create a form that sets the current date and time as the initial value,
152+ you can use the <code >DateOrToday</code > and <code >TimeOrNow</code > properties.
153+ </p >
154+ <pre ><code class =" language-razor" >Value: @@( Dt ? .ToString (" yyyy-MM-dd HH:mm:ssK" ) ?? " Not specified yet" )
155+ < ; br /> ;
156+ < ; LocalTimeForm @@bind-Value="Dt" Context="dtf"> ;
157+ < ; InputDate Type="InputDateType.Date" @@bind-Value="dtf.DateOrToday" /> ;
158+ < ; InputDate Type="InputDateType.Time" @@bind-Value="dtf.TimeOrNow" /> ;
159+ < ; button @@onclick="() => ; Dt = null"> ; Reset< ; /button> ;
160+ < ; /LocalTimeForm> ;
161+
162+ @@code {
163+ private DateTime ? Dt { get ; set ; } = DateTime .UtcNow ;
164+ }
165+ </code ></pre >
166+
167+ <div class =" component-sample" >
168+ Value: @( Dt2 ? .ToString (" yyyy-MM-dd HH:mm:ssK" ) ?? " Not specified yet" )
169+ <br />
170+ <LocalTimeForm @bind-Value =" Dt2" Context =" dtf" >
171+ <InputDate Type =" InputDateType.Date" @bind-Value =" dtf.DateOrToday" />
172+ <InputDate Type =" InputDateType.Time" @bind-Value =" dtf.TimeOrNow" />
173+ <button @onclick =" () => Dt2 = null" >Reset</button >
174+ </LocalTimeForm >
175+ </div >
176+
150177<h2 >Using with UI Libraries</h2 >
151178
152179<p >
@@ -321,6 +348,7 @@ Current Time: <LocalTimeText Value="@@DateTime.UtcNow" Format="yyyy-MM-dd HH:
321348@inject ILocalTimeService LocalTimeService
322349@code {
323350 private DateTime ? Dt { get ; set ; } = DateTime .UtcNow ;
351+ private DateTime ? Dt2 { get ; set ; }
324352
325353 private DateTimeOffset ? LocalDt { get ; set ; }
326354 private void ButtonClicked ()
You can’t perform that action at this time.
0 commit comments