Firetron’s FormatDateTime

1 331 Views No Comments 11 months ago
  • Formats a unix datetime number (to “YYYY-MM-DD at HH:MM” by default).

    Custom Command Dependencies:
    None

    Test Script:

    if not Load('done', false) then
    
      local dateDelimiter
      local dateTimeDelimiter
      local timeDelimiter
      local includeSeconds
      local includeTime
      local includeYear
    
      local unix = Time()
    
      local formatted = CC_FormatDateTime(unix)
    
      Log(' ')
      Log(formatted)
      Log('Formatted Default:')
      Log(' ')
    
      includeSeconds = true
      local formatted1 = CC_FormatDateTime(unix, dateDelimiter, dateTimeDelimiter, timeDelimiter, includeSeconds, includeTime, includeYear)
    
      Log(formatted1)
      Log('With Seconds:')
      Log(' ')
    
      includeTime = false
      local formatted2 = CC_FormatDateTime(unix, dateDelimiter, dateTimeDelimiter, timeDelimiter, includeSeconds, includeTime, includeYear)
    
      Log(formatted2)
      Log('Without Time:')
      Log(' ')
    
      includeTime = true
      includeYear = false
      local formatted3 = CC_FormatDateTime(unix, dateDelimiter, dateTimeDelimiter, timeDelimiter, includeSeconds, includeTime, includeYear)
    
      Log(formatted3)
      Log('Without Year:')
      Log(' ')
    
      dateDelimiter = '/'
      dateTimeDelimiter = ' - '
      timeDelimiter = '.'
      includeSeconds = true
      includeTime = true
      includeYear = true
      local formatted4 = CC_FormatDateTime(unix, dateDelimiter, dateTimeDelimiter, timeDelimiter, includeSeconds, includeTime, includeYear)
    
      Log(formatted4)
      Log('Formatted Another Way:')
      Log(' ')
    
      Save('done', true)
    
    end
    • This topic was modified 11 months, 1 week ago by Team HaasScripts.
    • This topic was modified 10 months, 2 weeks ago by Firetron. Reason: Added hyperlink to command
    • This topic was modified 5 months, 2 weeks ago by Firetron. Reason: Removed tip addresses
    • This topic was modified 3 weeks, 5 days ago by Firetron. Reason: Added params to customize format. Added test script
    • This topic was modified 3 weeks, 5 days ago by Firetron. Reason: Changed test code
    • This topic was modified 3 weeks, 5 days ago by Firetron. Reason: Changed test code
    • This topic was modified 3 weeks, 5 days ago by Firetron. Reason: Changed a section header
    HaasScript Code
    Sign in or Register to view
Login or Register to Comment

Unlock your crypto trading potential

Create a free account and enjoy everything we have to offer.

Join for Free