M
matg
I've cobbled together a subroutine to get a timestamp and create a
further string that represents the previous day.
Can anyone improve on this .. it seems very klunky.. and I'm sure
there's a neater way to do things..
the code:...................
###########################
#
# creates timestamp from current date
# adds a leading 0 to the month and day string
# and works on previous day
#
###########################
sub create_timestamp{
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time);
if ($year == "102"){;
$year = "2002";
}
if ($year == "103"){;
$year = "2003";
}
if ($year == "104"){;
$year = "2004";
}
if ($year == "105"){;
$year = "2005";
}
if ($year == "105"){;
$year = "2005";
}
if ($year == "106"){;
$year = "2006";
}
if ($mon== "0"){
$month = "01"
}
if ($mon== "1"){
$month = "02"
}
if ($mon== "2"){
$month = "03"
}
if ($mon== "3"){
$month = "04"
}
if ($mon== "4"){
$month = "05"
}
if ($mon== "5"){
$month = "06"
}
if ($mon== "6"){
$month = "07"
}
if ($mon== "7"){
$month = "08"
}
if ($mon== "8"){
$month = "09"
}
if ($mon== "9"){
$month = "10"
}
if ($mon== "10"){
$month = "11"
}
if ($mon== "11"){
$month = "12"
}
if ($mday > 10){
$previous_day=($mday-1)
}
if ($mday == "2") {
$previous_day="01";
}
if ($mday == "3") {
$previous_day="02";
}
if ($mday == "4") {
$previous_day="03";
}
if ($mday == "5") {
$previous_day="04";
}
if ($mday == "6") {
$previous_day="05";
}
if ($mday == "7") {
$previous_day="06";
}
if ($mday == "8") {
$previous_day="07";
}
if ($mday == "9") {
$previous_day="08";
}
if ($mday == "10") {
$previous_day="09";
}
$timestamp = "$month$previous_day";
}
further string that represents the previous day.
Can anyone improve on this .. it seems very klunky.. and I'm sure
there's a neater way to do things..
the code:...................
###########################
#
# creates timestamp from current date
# adds a leading 0 to the month and day string
# and works on previous day
#
###########################
sub create_timestamp{
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time);
if ($year == "102"){;
$year = "2002";
}
if ($year == "103"){;
$year = "2003";
}
if ($year == "104"){;
$year = "2004";
}
if ($year == "105"){;
$year = "2005";
}
if ($year == "105"){;
$year = "2005";
}
if ($year == "106"){;
$year = "2006";
}
if ($mon== "0"){
$month = "01"
}
if ($mon== "1"){
$month = "02"
}
if ($mon== "2"){
$month = "03"
}
if ($mon== "3"){
$month = "04"
}
if ($mon== "4"){
$month = "05"
}
if ($mon== "5"){
$month = "06"
}
if ($mon== "6"){
$month = "07"
}
if ($mon== "7"){
$month = "08"
}
if ($mon== "8"){
$month = "09"
}
if ($mon== "9"){
$month = "10"
}
if ($mon== "10"){
$month = "11"
}
if ($mon== "11"){
$month = "12"
}
if ($mday > 10){
$previous_day=($mday-1)
}
if ($mday == "2") {
$previous_day="01";
}
if ($mday == "3") {
$previous_day="02";
}
if ($mday == "4") {
$previous_day="03";
}
if ($mday == "5") {
$previous_day="04";
}
if ($mday == "6") {
$previous_day="05";
}
if ($mday == "7") {
$previous_day="06";
}
if ($mday == "8") {
$previous_day="07";
}
if ($mday == "9") {
$previous_day="08";
}
if ($mday == "10") {
$previous_day="09";
}
$timestamp = "$month$previous_day";
}