All Scripts backed by 10 years in business, free support, free updates and a 30 day money back guarantee.
Download Purchase Programming F.A.Q. Support Contact
Commercial Perl Scripts
All Form Pro Updated
Count It
Form Mailer + Attachments
Client File Manager
Da Godfaddah
Dropbox Updated
FAQ Builder
HT Manager Updated
RegisterHT
Mailing List Server
Page Updater - Text
Page Updater Pro Updated
PS Guestbook Updated
PS Lightning Search Updated
Quick File Mailer
Quick MySQL
Select-A-File
Upload Center
Free Perl Scripts
Access Log Viewer
All Form
Epoch Converter
Error Log Viewer
Invoice Center
PS Upload
Question Manager
Quick CHMOD
QuickHT
Site File Finder
Site File Lister
SSI Tag Maker
Perl Modules
Monger Calendar
Monger File
Monger Mail
Monger Persist
JavaScript Generators
PopUp Windows
Meta Gen
RGB / Hex Converter
Page Colors
Sudoku
Tutorials and FAQs
Cookies
Using CuteFTP
Using WS_FTP
Installing Scripts
Debugging
Utilities
env_vars.pl
backup.pl
restore.pl
check_email.pl
date.pl
dayname.pl
fileage.pl
format_length.pl
format_url.pl
getfile.pl
parse.pl
redirect_html.pl
Free Services
Epoch Converter
TLD Registries
RGB/Hex FInder
Colour Checker
ASCII Codes
Policies
Terms and Conditions
Privacy Policy
Refund Policy
Site Map

Form Processor with no SPAM from robots.

Anti-spam, anti-robot, anti-flame, Guestbook for your website.

Manage Remote websites from your website. Allow clients to update sections of their own web pages.

Secure file manager with upload progress meter. A printer's best friend. Find out more.

Utility Name: dayname.pl
Platform: UNIX or Linux
Requires: Perl4 or higher


[Demonstration]


This utility takes the input year, month and day (all in digits) and then returns the name of the day. How is this possible? Easy! The names of days always follow the same pattern:

Sunday, Monday, Tuesday, Wednesday,
Thursday, Friday, Saturday

Because of this, the appearance of a certain day name follows a constant mathematical formula. This subroutine/utility has had that mathematical formula written into it along with the dynamic generation of certain constants which will affect the outcome. (i.e. leap years).

The subroutine calculates Leap Years on it's own and makes all necessary adjustments for them.

To use this subroutine you must pass three arguments and there are a few rules about these arguments. The three arguments, in order are the Year, the Month and the Day of the Month for which you want to return a day's name.

Here are the rules for the arguments being passed:

  1. The arguments must all be DIGITS. You can not pass, for example, the word 'August'.
  2. The year argument MUST be four digits long.
    i.e.: 1998 is valid, 98 is not valid.
  3. The year argument must be equal to or greater than 1800 and less than or equal to 2099.
  4. The subroutine will check to ensure that the day of month submitted does not exceed the permitted number of days in that month. For example, submitting 31 as the day of the month is valid for July but it is NOT valid for June.

If you violate any of these above rules the subroutine will return a null value (zero). If you successfully pass the above arguments, then the subroutine will return the name of the day corresponding to the day of month, month and year submitted.

Here are some examples of calls to the subroutine:

EX.1
$year = 1965;
$month = 6;
$day = 19;
$name_of_day = dayname($year, $month, $day);

EX.2
$name_of_day = dayname(1965, 6, 19);

EX.3
$year = 1965;
push(@date_arguments, $year);
$month = 6;
push(@date_arguments, $month);
$day = 19;
push(@date_arguments, $day);
$name_of_day = dayname(@date_arguments);

EX.4
$month = 6;
$day = 19;
$name_of_day = dayname(1965, $month, $day);

NOTE: If your on the ball then you realized you can also use this subroutine simply to ensure that the user has submitted a valid date that exists between the years 1800 and 2099. To do this you will make the subroutine part of a test for a logical loop. Here is an example:
if(dayname($year, $month, $day)) {

	YOUR LOGICAL BLOCK HERE. THIS LOGICAL
	BLOCK WILL EXECUTE IF THE DATE SUBMITTED
	IS A VALID DATE.

} else {

	YOUR ERROR TRAP HERE. IT WILL EXECUTE
	IF THE DAY SUBMITTED IS TOO BIG FOR THE
	MONTH SUBMITTED or a violation of any of
	the other argument rules.

}

[Demonstration]

To use this subroutine either cut and paste it into your own script or simply require this script anywhere before you first call the subroutine by simply placing the following line in your script (without the hash mark of course):

require 'dayname.pl';

  ©2009 All rights reserved, PerlServices.net. Website hosting by LinuxHostingPlans.com