标签类目:time

Python 时间戳转换

分类:Python

#!/bin/env python
import time
print time.time()

1255334367.7758279

print time.ctime(1255334367.7758279)

Mon Oct 12 15:59:27 2009

#date +%s

  1255332871

#date -d '1970-01-01 1255332871 seconds' +"%Y-%m-%d %T"

  2009-10-12 07:34:31

测量/计算程序运行时间

分类:C/C++C/C++中的计时函数是clock(),而与其相关的数据类型是clock_t。在MSDN中,查得对clock函数定义如下:

clock_t clock( void );

这个函数返回从“开启这个程序进程”到“程序中调用clock()函数”时之间的CPU时钟计时单元(clock tick)数,在MSDN中称之为挂钟时间(wal-clock)。其中clock_t是用来保存时间的数据类型,在time.h文件中,我们可以找到对它的定义:

  1. #ifndef _CLOCK_T_DEFINED
  2. typedef long clock_t;
  3. #define _CLOCK_T_DEFINED
  4. #endif

继续阅读 »

Python TKinter Gui:Time Tools, Threads, and Animation

分类:PythonThe last stop on our widget tour is the most unique. Tkinter also comes with a handful of tools that have to do with the event-driven programming model, not graphics displayed on a computer screen.

Some GUI applications need to perform background activities. periodically. For example, to “blink” a widget’s appearance, we’d like to register a callback handler to be invoked at regular time intervals. Similarly, it’s not a good idea to let a long-running file operation block other activity in a GUI; if the event loop could be forced to update periodically, the GUI could remain responsive. Tkinter comes with tools for both scheduling such delayed actions and forcing screen updates: 继续阅读 »

Linux Shell Script: 時間計算

分类:Shell

  • 現在時間 + 22:09:53 = 何時?
  • 現在時間 + 128 分鐘 = 何時?

#!/bin/bash

# User Defined Variables
# H,M,S  系統時間
# rhflag 0 = 當日, 1 = 明天, 2 = 後天…
# strUsage 參數提示訊息
# timeoffset 使用者輸入的時間 (時:分:秒)
# oh,om,os 從 timeoffset 提列出來的 時, 分, 秒 (case 1) / 進位值 (case 2)
# rh,rm,rs 運算結果 時, 分, 秒
# offset 使用 -h, -m, -s 參數時, 使用者帶入的數值 继续阅读 »


返回顶部