From faa68d76f0ee65cd148785927324bf1454b77172 Mon Sep 17 00:00:00 2001 From: Mark Crowther Date: Sat, 27 Jun 2020 16:47:35 +0100 Subject: [PATCH 1/2] Adding an old script for getting the day, data, month and year --- myDayFunction.js | 112 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 myDayFunction.js diff --git a/myDayFunction.js b/myDayFunction.js new file mode 100644 index 0000000..0c28609 --- /dev/null +++ b/myDayFunction.js @@ -0,0 +1,112 @@ +/* An old script I wrote back in 2012 - I'll 'improve' it later. */ +function mydayfunction() { + + var d = new Date(); + var date = d.getDate(); + var day = d.getDay(); + var month = d.getMonth(); + var year = d.getFullYear(); + + /* Append the correct date type */ + if (date==1 || date==21 || date==31) { + date = date + "st"; + } + else if (date==2 || date==22) { + date = date + "nd"; + } + else if (date==3 || date==23) { + date = date + "rd"; + } + else if (date > 3) { + date = date + "th"; + } + + /* Change the numeric date value to the name */ + switch (day) { + case 0: + day = "Sunday"; + break; + + case 1: + day = "Monday"; + break; + + case 2: + day = "Tuesday"; + break; + + case 3: + day = "Wednesday"; + break; + + case 4: + day = "Thursday"; + break; + + case 5: + day = "Friday"; + break; + + case 6: + day = "Saturday"; + break; + + } + + /* Change the numeric month value to the name */ + switch (month) { + case 0: + month = "January "; + break; + + case 1: + month = "February "; + break; + + case 2: + month = "March "; + break; + + case 3: + month = "April "; + break; + + case 4: + month = "May "; + break; + + case 5: + month = "June "; + break; + + case 6: + month = "July "; + break; + + case 7: + month = "August "; + break; + + case 8: + month = "September "; + break; + + case 9: + month = "October " + break; + + case 10: + month = "November " + break; + + case 11: + month = "December " + break; + } + + /* Write everything out */ + document.write("
"); + document.write(day + ", " + date + " " + month + " " + year); + document.write("
"); + + } \ No newline at end of file From 4fb1b64ad7269a6cb1f9843e55df1b58af15e860 Mon Sep 17 00:00:00 2001 From: Mark Crowther Date: Mon, 29 Jun 2020 12:47:33 +0100 Subject: [PATCH 2/2] updated the files and html page --- .../myDayFunction.js | 26 +++++++++---------- DateAndTime/myDayFunctionExample.html | 12 +++++++++ DateAndTime/myYearAndDate.js | 13 ++++++++++ DateAndTime/style.css | 5 ++++ 4 files changed, 43 insertions(+), 13 deletions(-) rename myDayFunction.js => DateAndTime/myDayFunction.js (80%) create mode 100644 DateAndTime/myDayFunctionExample.html create mode 100644 DateAndTime/myYearAndDate.js create mode 100644 DateAndTime/style.css diff --git a/myDayFunction.js b/DateAndTime/myDayFunction.js similarity index 80% rename from myDayFunction.js rename to DateAndTime/myDayFunction.js index 0c28609..205546e 100644 --- a/myDayFunction.js +++ b/DateAndTime/myDayFunction.js @@ -1,5 +1,5 @@ /* An old script I wrote back in 2012 - I'll 'improve' it later. */ -function mydayfunction() { +function myDayFunction() { var d = new Date(); var date = d.getDate(); @@ -56,19 +56,19 @@ function mydayfunction() { /* Change the numeric month value to the name */ switch (month) { case 0: - month = "January "; + month = "January"; break; case 1: - month = "February "; + month = "February"; break; case 2: - month = "March "; + month = "March"; break; case 3: - month = "April "; + month = "April"; break; case 4: @@ -76,37 +76,37 @@ function mydayfunction() { break; case 5: - month = "June "; + month = "June"; break; case 6: - month = "July "; + month = "July"; break; case 7: - month = "August "; + month = "August"; break; case 8: - month = "September "; + month = "September"; break; case 9: - month = "October " + month = "October"; break; case 10: - month = "November " + month = "November"; break; case 11: - month = "December " + month = "December"; break; } /* Write everything out */ document.write("
"); - document.write(day + ", " + date + " " + month + " " + year); + document.write(day + ", " + date + " " + month + ", " + year); document.write("
"); } \ No newline at end of file diff --git a/DateAndTime/myDayFunctionExample.html b/DateAndTime/myDayFunctionExample.html new file mode 100644 index 0000000..90b611a --- /dev/null +++ b/DateAndTime/myDayFunctionExample.html @@ -0,0 +1,12 @@ + + + My Day Function Example + + + + + + +
+
+ \ No newline at end of file diff --git a/DateAndTime/myYearAndDate.js b/DateAndTime/myYearAndDate.js new file mode 100644 index 0000000..7dc2976 --- /dev/null +++ b/DateAndTime/myYearAndDate.js @@ -0,0 +1,13 @@ +/* An old script I wrote back in 2012 - I'll 'improve' it later. */ + +function myYearAndDate() { + + var d = new Date(); + var year = d.getFullYear(); + + /* Write everything out */ + document.write("
"); + document.write("Write a ©" + year + " statement that never goes out of date.
"); + document.write("
"); + + } \ No newline at end of file diff --git a/DateAndTime/style.css b/DateAndTime/style.css new file mode 100644 index 0000000..21865f3 --- /dev/null +++ b/DateAndTime/style.css @@ -0,0 +1,5 @@ +/* main styles */ +body { padding:0; margin:10; vertical-align:top; background:#ffffff; font-family:Tahoma;} + +.datetxt {color:#5A0F0F; font-size:20px;} +.footertxt {font-size:10px;} \ No newline at end of file