| | 1 | | @using System.Text |
| | 2 | | @inject IJSRuntime JSRuntime |
| | 3 | |
|
| | 4 | | <div class="container"> |
| | 5 | |
|
| | 6 | | <div class="row"> |
| | 7 | | <div class="col"> |
| | 8 | | <h2>⏱️ Time Converter</h2> |
| | 9 | | </div> |
| | 10 | | </div> |
| | 11 | |
|
| | 12 | | <div class="row"> |
| | 13 | | <div class="col"> |
| | 14 | | <div class="input-group"> |
| | 15 | | <div class="input-group-prepend"> |
| | 16 | | <span class="input-group-text">Seconds:</span> |
| | 17 | | </div> |
| | 18 | | <input type="number" id="input" class="form-control" @bind="Input" placeholder="60" /> |
| | 19 | | <span class="input-group-btn"> |
| | 20 | | <button id="btnClear" name="btnBinaryClear" class="btn btn-danger float-right" @onclick="Clear"><i c |
| | 21 | | </span> |
| | 22 | | </div> |
| | 23 | | </div> |
| | 24 | | </div> |
| | 25 | |
|
| | 26 | | <div class="row"> |
| | 27 | | <div class="col"> |
| | 28 | | <button id="btnConvert" name="btnConvert" class="btn btn-success float-right" @onclick="Convert">Convert</bu |
| | 29 | | </div> |
| | 30 | | </div> |
| | 31 | |
|
| | 32 | | <div class="row"> |
| | 33 | | <div class="col"> |
| | 34 | | <div class="input-group"> |
| | 35 | | <div class="input-group-prepend"> |
| | 36 | | <span class="input-group-text">hh:mm:ss:fff</span> |
| | 37 | | </div> |
| | 38 | | <input id="output" class="form-control" @bind="Output" placeholder="hh:mm:ss:fff" readonly="readonly" /> |
| | 39 | | <span class="input-group-btn"> |
| | 40 | | <button id="btnCopy" name="btnCopy" class="btn btn-info float-right" @onclick="Copy"><i class="far f |
| | 41 | | </span> |
| | 42 | | </div> |
| | 43 | |
|
| | 44 | | </div> |
| | 45 | | </div> |
| | 46 | |
|
| | 47 | | </div> |
| | 48 | |
|
| | 49 | | @code { |
| 0 | 50 | | long Input = 60; |
| 0 | 51 | | string Output = string.Empty; |
| | 52 | |
|
| | 53 | | void Convert() |
| 0 | 54 | | { |
| 0 | 55 | | var data = ConvertTime(Input); |
| 0 | 56 | | Output = data; |
| 0 | 57 | | } |
| | 58 | |
|
| | 59 | | private void Clear() |
| 0 | 60 | | { |
| 0 | 61 | | Input = 0; |
| 0 | 62 | | } |
| | 63 | |
|
| | 64 | | async Task Copy() |
| 0 | 65 | | { |
| 0 | 66 | | await JSRuntime.InvokeVoidAsync("navigator.clipboard.writeText", Output); |
| 0 | 67 | | } |
| | 68 | |
|
| | 69 | | #region Convert |
| | 70 | | static string ConvertTime(long seconds) |
| 0 | 71 | | { |
| 0 | 72 | | TimeSpan time = TimeSpan.FromSeconds(seconds); |
| 0 | 73 | | return time.ToString(@"hh\:mm\:ss\:fff"); |
| 0 | 74 | | } |
| | 75 | | #endregion Convert |
| | 76 | | } |