Split time string to value
(Automatically adding template at the end of the page.)
(Adding message template to the top of the page)
Line 1: Line 1:
{{message|Write the content here to display this box}}
I was asked how to split a string from a textbox to its given hour and minute values.
I was asked how to split a string from a textbox to its given hour and minute values.
  let x='22:12'.split(':'.tochararray) in
  let x='22:12'.split(':'.tochararray) in

Revision as of 22:36, 16 June 2024

Write the content here to display this box

I was asked how to split a string from a textbox to its given hour and minute values.

let x='22:12'.split(':'.tochararray) in
(
  Integer.Parse(x.at0(0)).asstring+' hours and '+Integer.Parse(x.at0(1)).asstring+' minutes'
)

Why, you ask? Well, consider having this in a ReverseDerived string representing the clock. Once you have the parts, you can update a Datetime value with these for storage.

Or maybe do something like this:

let x='22:12'.split(':'.tochararray) in(
  DateTime.Parse('0001-01-01 '+x.at0(0)+':'+x.at0(1))
)

Later, I found that this article addresses the same issue in a wider context together with the derived settable attribute here: Derived settable attributes.

This page was edited 15 days ago on 06/17/2024. What links here