For measure working time on windows I wrote a little script. It calculates the time since the last login. The output of the script looks like this:
Login: 10:10
Now: 18:13
======================
Working time: 8 h 3 m
The script is written in Ruby and runs under
cygwin. I saved the script in a folder tools in my homedir and have the following alias in my .bashrc:
alias wt='~/tools/workingtime.rb'
So finally the script looks like this:
#!/usr/bin/ruby
HOURS_PER_DAY = 24
MINUTES_PER_HOUR = 60
SEC_PER_MINUTE = 60
times = []
#get times from windows systeminfo
#Systembetriebszeit: 0 Tage, 0 Stunden, 10 Minuten, 0 Sekunden
uptime_string = `systeminfo | grep Systembetriebszeit`
uptime_string.slice!(0..28)
time_strings = uptime_string.split(',')
time_strings.each do |s|
times
Known issues:
The script is based on the windows command systeminfo. Systeminfo returns values in the language of the operating system. So this works only with a german windows. Replace "Systembetriebszeit" with whatever your systeminfo command returns for the uptime.
Update:
Workingtime.rb moves to github. Follow the installation instructions
there.
You may also like
I just changed the url of this blog to https://jensjaeger.com. TLS encryption is now the default for all request to this page. It might be possible that some image links on some articles are hard coded http. If you find such an error it would be nice if you leave me comment so i can
Read More
Prettytime is a nice java library to format a java Date()s in a nice humanized ago format, like: moments ago 2 minutes ago 13 hours ago 7 months ago 2 years ago Prettytime is localized in over 30 languages. It’s super simple to use Add the dependency to your maven pom: org.ocpsoft.prettytime prettytime 3.2.7.Final or
Read More