About RIPE NCC | Contact  | Search | Sitemap    
Homepage RIPE NCC  
Test Traffic Measurements
     
TTM:
RIPE NCC Navigation Ends
TTM Home Page
Sign up for TTM service
For Current Hosts
TTM Data
FAQs
Presentations
Documentation
Contact
News
RIPE NCC Navigation Ends
Next Section

Test Traffic Project

Localtime

The following script converts a Unix timestamp into a UTC timestamp:
#!/bin/sh
#
# localtime - print local and GMT time
#
#  -- Rene  19990114
#
#==========

for i in $@
do
echo "Clock:            $i"
unset TZ
echo "Local Time:       " `perl5 -e "print scalar localtime($i)"`
export TZ=GMT0GMT0
echo "GMT/UTC:          " `perl5 -e "print scalar localtime($i)"`
echo
done

Copy the script into a file, save and make executable. The script reads all arguments and transforms them into a normal timestamp, e.g:

$ localtime 1 31536000
Clock:           1
Local Time:      Thu Jan 1 01:00:01 1970
GMT/UTC:         Thu Jan 1 00:00:01 1970

Clock:           31536000
Local Time:      Fri Jan 1 01:00:00 1971
GMT/UTC:         Fri Jan 1 00:00:00 1971
Since UNIX time starts on 1/1/1970, "localtime 1" should be 1 second past midnight. 1 year is equal to 365 days * 24 hours * 3600 seconds, or 31536000, so "localtime 31536000" should return 1/1/1971. We are in the European timezone, and that is 1 hour ahead of UTC/GMT.

This script won't win any prizes for nice programming. That wasn't intended either, we just needed something to do the job.

 

Next Section
     About RIPE NCC | Service Announcements | Site Map | LIR Portal | About RIPE | Contact | Legal | Copyright Statement
RIPE NCC Homepage Go to the RIPE NCC LIRPortal Go to the RIPE Community pages