#!/usr/bin/perl

# turn on perl's safety features
use strict;
use warnings;

### use Date::Parse;
use Data::Dumper;
my $start_time = time();

print "Hello, World: Started on " . localtime($start_time) . "\n";

my @locations = (
"Surry Hills Market",
"North Sydney Markets",
"Crows Nest Market",
"Kirribilli Markets",
"Potts Point 153 Victoria Street",
"Potts Point 153 Victoria Street",
"Potts Point 153 Victoria Street",
"King Cross Rotary Markets Macleay Street" );

my @timesets = (
"1st Saturday 7am to 3:30pm",
"2nd Saturday 7am to 3:30pm",
"3rd Saturday 7am to 3:30pm",
"4th Saturday 7am to 3:30pm",
"5th Saturday 9am to 8pm",
"every Friday 4pm to 8pm",
"every Saturday 4pm to 9pm",
"every Sunday 9am to 6:30pm" );

my $loc;
my $tme;
my $cnt;
$cnt = 0;
foreach $loc (@locations) {
	$tme = $timesets[$cnt];
	print "$loc $tme\n";
	$cnt++;
}

#my $date  = Date::Simple->new('1972-01-17');
#	my $year  = $date->year;
#    my $month = $date->month;
#    my $day   = $date->day;
#    my $date2 = Date::Simple->new($year, $month, $day);
#    my $today = Date::Simple->new;
#    my $tomorrow = $today + 1;
#    print "Tomorrow's date (in ISO 8601 format) is $tomorrow.\n";
#    if ($tomorrow->year != $today->year) {
#        print "Today is New Year's Eve!\n";
#    }
#    if ($today > $tomorrow) {
#        die "warp in space-time continuum";
#    }
    # you can also do this:
    #($date cmp "2001-07-01")
    # and this
    #($date <=> [2001, 7, 1])
my @mthlist = ("January","February","March","April","May","June","July",
"August","September","October","November","December");
my @daylist = ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");

print "Started on " . localtime($start_time) . "\n";
my @mcdate = localtime(time());
my $Today = $mcdate[3];
my $hour = $mcdate[2]; # current hour
my $mins = $mcdate[1]; # and minutes

my $mth = $mcdate[4]; # month
my $Month = $mthlist[$mth];
print "Month = $mth = $Month\n";
my $yr = $mcdate[5]; # year
if ($yr < 2000) {
	$yr += 1900;
}
if ($yr < 2000) {
	$yr += 100;
}
my $Year = $yr;
my $dow = $mcdate[6];
my $Day = $daylist[$dow];
if ($hour < 10) {
	$hour = ("0" . $hour);
}
if ($mins < 10) {
	$mins = "0" . $mins;
}

#function ModifiedDate() {
#var month = new Array("January","February","March","April","May","June","July",
#					  "August","September","October","November","December");
#var updated = new Date(document.lastModified);
#var Month   = month[updated.getMonth()];
#var Day     = updated.getDate();
#var Year    = updated.getYear();
#var Hour    = updated.getHours();
#var Min     = updated.getMinutes();
#	if( Year < 2000 ) Year += 1900;
#	if( Year < 2000 ) Year += 100;  //Netscape 3 and IE 4.7 return 0 instead of 100 for 2000
#	if( Hour < 10 )  Hour = "0" + Hour;
#	if( Min  < 10 )  Min  = "0" + Min;
#	document.write("Last modified " + Month + " " + Day +  ", " + Year + " at " + Hour + ":" + Min);
#}

my $tm = "$hour:$mins";
print "This is [$Day] [$Today] [$Month] of [$Year] at [$tm]\n";

##Started on Thu Jun 23 15:23:52 2005
##This is [23]
#print Dumper(@mcdate);
##$VAR0 = 52;
##$VAR1 = 23;
##$VAR2 = 15;

##$VAR3 = 23;
##$VAR4 = 5;
##$VAR5 = 105;

##$VAR6 = 4; ### dayofweek
##$VAR7 = 173;
##$VAR6 = 0;
##my @targs = ("15", "23", "52");
  # get what was specified on the command line
##  my $time = join ' ', @ARGV;
##my $my_time = join ' ', @targs;
# convert that to seconds
##my $my_secs = str2time($my_time);
# check we got something useful back
##unless (defined $my_secs)
##   { die "Can't parse '$my_time' as a time or date\n" }
  # print out the result
##  print "'$my_time' parses as:\n",
##        "'$my_secs' (".gmtime($my_secs).")\n";

#eof
