Seconds to Time in XSLT

后端 未结 2 1387
孤城傲影
孤城傲影 2020-12-12 02:06

I\'m not asking a question actually. I signed up stackoverflow to give something back to a community that has helped me so many times.

If you are using XSLT 1.0 the

2条回答
  •  一向
    一向 (楼主)
    2020-12-12 02:28

    Firt of all, thank you for your contribution. There are, however, a few issues with this implementation. The seconds output doesn't take the leading 0 into account, but even if that's fixed, the output can be ambiguous if any of the figures happens to be 0. For example, the inputs 36005, 605, and 36300 all produce the result 10:05.

    Likewise if two of the figures happen to be zero. The input 36000 produces the output 10:, and the inputs 600 and 10 both produce the result 10.

    Here is how I would go about implementing this functionality:

      
        
        
        
    
        
          
        
    
        
    
        
          
        
      
    

    This way, hours are only displayed if they are non-zero or optionally turned on, and seconds are included by default, but can be optionally omitted by using the parameter values. This should reduce the ambiguity about what a time is supposed to represent.

    It also allows omitting the value parameter if the value you want to format is the current context node.

提交回复
热议问题