#!/bin/sh # *********************************************************************** # # * * # # * Copyright (c) 1996-1999 Scott Crevier * # # * All Rights Reserved Worldwide * # # * * # # * This program product material is the property of Scott Crevier. * # # * This program may be used and modified by anyone free of charge, * # # * as long as this copyright notice remains in tact. By using this * # # * code, you agree to indemnify Scott Crevier from any liability * # # * that might arise from its use. * # # * * # # * scott@crevier.org - Scott M. Crevier - www.crevier.org * # # *********************************************************************** # # * smcDate v2.0 21-Dec-1998 * # # * * # # * This script displays the current date/time in any time zone and * # # * compensates for daylight savings time. * # # * * # # * Suggested usage: * # # * * # # * * # # * Where: 'zone' is a one-digit time zone code as recognized by the * # # * case statement below. * # # *********************************************************************** # echo "Content-type: text/plain" echo # *********************************************************************** # # * Determine the timezone to use. * # # * * # # * I've tried to make it simple here by allowing a one character * # # * argument. Based on that argument, I set the proper variable so * # # * that daylight savings time is handled. For example, if I * # # * indicate the letter 'P', the script will display the correct * # # * Pacific time, whether daylight savings time is in effect or not. * # # * * # # * Since I live in the United States, my code covers most of the * # # * time zones used here. If there are other timezones that you need * # # * to use, just add the corresponding code to the case statement * # # * below. Or if you will always use only one time zone, then you * # # * might find it beneficial to just remove the case statement * # # * completely and hard code it. * # # *********************************************************************** # case $QUERY_STRING in A|a) export TZ=AST9ADT # Alaskan Time ;; P|p) export TZ=PST8PDT # Pacific Time ;; M|m) export TZ=MST7MDT # Mountain Time ;; C|c) export TZ=CST6CDT # Central Time ;; E|e) export TZ=EST5EDT # Eastern Time ;; G|g) export TZ=GMT0 # Greenwich Mean Time ;; U|u) export TZ=UTC0 # Universal Time Coordinated ;; *) echo "ERROR: Invalid timezone specifier '${QUERY_STRING}'." exit 1 ;; esac # *********************************************************************** # # * Display the date/time and exit. * # # * * # # * Okay, so I went nuts with the following date command; I'm real * # # * picky about my date and time formats. You can also just run the * # # * 'date' command with no arguments and it'll work just fine. * # # *********************************************************************** # date '+%a, %d-%b-%y at %I:%M:%S%p %Z' | sed s/AM/am/ | sed s/PM/pm/ exit 0