File: utime

package info (click to toggle)
epic4 1%3A3.0-2.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,756 kB
  • sloc: ansic: 56,285; makefile: 631; sh: 161; perl: 30
file content (53 lines) | stat: -rw-r--r-- 1,153 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#
# Here's the plan
# Kanan wants a way to manipulate $utime() values.  Because theyre 
# thrown about as two words, we cant actually have the math parser
# handle them automatically (alas), and writing built in functions
# just to do this seems like overkill.  So i wrote these aliases for
# his (and your) convenience.  Use this is as a starting point for you
# own alias needs, or drop me a line if you have more suggestions.
# (jnelson@acronet.net)
#

#
# Add two utimes.
#
alias utime_add 
{
	local sec,usec
	@ sec = [$0] + [$2]
	@ usec = [$1] + [$3]
	if (usec > 1000000)
	{
		@ usec -= 1000000, sec++
	}
	@ function_return = sec ## [ ] ## right(6 000000$usec)
}

#
# Subtract two utimes.  The LARGER utime (the more recent) should
# be the first one specified
#
alias utime_sub
{
	local sec,usec
	@ sec = [$0] - [$2]
	@ usec = [$1] - [$3]
	if (usec < 0)
	{
		@ usec += 1000000, sec--
	}
	@ function_return = sec ## [ ] ## right(6 000000$usec)
}

#
# You pass a utime as $0, $1, and this function will return
# how many useconds have passed since then.
#
alias time_since
{
	local now $utime()
	@ function_return = utime_sub($now $0 $1)
}

#hop'97