hyTags
HomeHome DocumentationDocumentation

time-from-string

Parses a time from a string using the specified format.
Parameter
Type
Description
string
String
The string to parse
format
String?
The format pattern to use for parsing
return
time
The parsed time, or nil if parsing fails
Test Case:Parse time string with seconds
    <div></div>
    
    <time-from-string string="14:30:45">
    <time-get component="hour">
    <assert-equal value="14" type="number">
    
    👆 Try to change something!
  • Test Case:Parse time string without seconds
      <div></div>
      
      <time-from-string string="14:30">
      <time-get component="minute">
      <assert-equal value="30" type="number">
      
      👆 Try to change something!
    • Test Case:Parse time string seconds default to zero
        <div></div>
        
        <time-from-string string="14:30">
        <time-get component="second">
        <assert-equal value="0" type="number">
        
        👆 Try to change something!
      • Test succeeded Test failed