• get date tcl tk


    The method to get Date Tcltk

    proc GetDate { args } {
    #---------------------------------------------------------------
    #d_sum Return the date/time appropriately formatted
    #d_desc Uses Tcl clock command.  Return the current time if the -clock \
    argument is not used.  See Tcl clock command for explanation of formats.
    #d_opt0 -clock time
    #d_opt1 Input a time as a machine clock time in seconds
    #d_opt0 -format format
    #d_opt1 Output format can be: full (%d %b %Y  %H:%M:%S), time (%H:%M:%S) \
    date (%d %b %Y), or brief (%H:%M:%S for today or %d %b %y)

    # If there is no input secs then find the current time
    # otherwise use the input time secs  and convert to user
    # friendly format   dependent on format input
    # full        full date and time
    # time        time only
    # date        date only
    # brief        time for any time today otherwise date
    #

      set format full
      set secs {}

      set nargs [llength $args]; set n 0
      while { $n < $nargs } {
        switch -regexp -- [lindex $args $n] \
        format {
          incr n; set format [lindex $args $n]
        } clock {
          incr n; set secs [lindex $args $n]
        }
        incr n
      }

      if { $secs == "" } { set secs [clock seconds] }
      if { [llength $secs ] > 1 } {
        if { $format == "brief" } {
          return [ append time [string range $secs 0 6] [string range $secs 9 10] ]
        } else {
          return $secs
        }
      }

      if { $format == "seconds"} { return $secs }
      if { $format == "full" } {
        set date [clock format $secs -format "%d %b %Y  %H:%M:%S" ]
      } elseif { $format == "time" } {
        set date [clock format $secs -format "%H:%M:%S" ]
      } elseif { $format == "date" } {
        set date [clock format $secs -format "%d %b %Y" ]
      } elseif { $format == "brief" } {
        set today [ clock format [clock seconds] -format "%Y %j" ]
        set input [ clock format $secs -format "%Y %j" ]
        if { [lindex $input 0 ] == [lindex $today 0 ] &&
             [lindex $input 1 ] == [lindex $today 1 ] } {
          set date [clock format $secs -format "%H:%M:%S" ]
        } else {
          set date [clock format $secs -format "%d %b %y" ]
        }
      }
      return "$date"
    }


    "Starting CCP4I application [GetDate]"
  • 相关阅读:
    洛谷 P1077 摆花
    洛谷 P2323 [HNOI2006]公路修建问题
    2017.10.17 模拟赛
    【渗透测试小白系列】之BurpSuite爆破High级别的DVWA(含CSRF-Token防爆破程序)
    【漏洞复现】之sudo提权漏洞(CVE-2019-14287)复现
    【漏洞复现】Maccms潜藏后门分析复现
    杂乱的计算机网络基础
    简述数据库管理
    【漏洞复现】之微信DLL劫持反弹shell复现
    【渗透测试小白系列】之简单使用Ettercap实现DNS劫持
  • 原文地址:https://www.cnblogs.com/greencolor/p/2020988.html
Copyright © 2020-2023  润新知