|
|
|
|
|
|
| |
| #!/bin/sh
# SAVE THIS CODE AS cala_day.sh
#
# Uses Zellers Congruence calculation to use a date and give
# the day of the week that date was.
#
# This function expects 3 Arguments,
# DAY MONTH YEAR
# then
# Returns a value between 0 and 6 to represent the day of the
# week where 0=Sun,1=Mon,...6=Sat
#
# e.g cala_day.sh 25 12 2005
#
# This formula is Year 2000 compliant.
# It is not compliant using dates previous to Oct 1752
#
# Adjust Month such that March becomes 1 month of
# year and Jan/Feb become 11/12 of previous year
# =============================================
if [ $MONTH -ge 3 ] ; then
MONTH=`expr $MONTH - 2`
else
MONTH=`expr $MONTH + 10`
fi
if [ $MONTH -eq 11 ] || [ $MONTH -eq 12 ] ; then
YEAR=`expr $YEAR - 1`
fi
# ==============================================
# Split YEAR into YEAR and CENTURY
# ================================
CENTURY=`expr $YEAR / 100`
YEAR=`expr $YEAR % 100`
# ================================
# Black Magic Time
# ================
# Z = (( 26*$MONTH - 2 ) / 10) + $DAY + $YEAR + ( $YEAR/4 ) + ( $CENTURY/4 ) - (
2 * $CENTURY) + 77) % 7
Z=`expr \( $MONTH \* 26 - 2 \) / 10`
Z=`expr $Z + $DAY + $YEAR`
Z=`expr $Z + $YEAR / 4`
Z=`expr $Z + $CENTURY / 4`
Z=`expr $Z - $CENTURY - $CENTURY + 77`
Z=`expr $Z % 7`
if [ $Z -lt 0 ] ; then
Z=`expr $Z + 7`
fi
# ================
echo $Z
# Sun 0
# Mon 1
# Tue 2
# Wed 3
# Thu 4
# Fri 5
# Sat 6
# ========================
} | | |
|
| A Timing Class Categories : PHP, PHP Classes, Date Time | | | Clock at Status Bar Categories : Java Script, HTML, Date Time | | | Finding the day of the week for a specific date.
Categories : PHP, Databases, MySQL, Date Time | | | A wrapper function to format dates coming from a databases with the
same syntax as PHP's date() function. Categories : Date Time, Databases, PHP | | | pcCalendar class - Allows for the creation of calendars in HTML pages. All output functions can be easily overridden, refer to article 1471 for an example.
Categories : PHP, Date Time, Calendar, PHP Classes | | | Simple Javascript CSS Digital Clock Categories : Java Script, Date Time, CSS, Beginner Guides, Web Design | | | Enchancing dd/mm/yyyy forms with unobtrusive javascript Categories : Java Script, HTML, User Interface, Date Time | | | PHP Round Clock - Must have Gif support to use this. Categories : PHP, Date Time, Graphics | | | MySql date format function Categories : MySQL, Date Time, Databases | | | A simple and fast calendar combining PHP and tables. Use this as a base for applications in which a calendar is needed. Categories : Date Time, PHP, Complete Programs, Calendar | | | mysql date/time converters Categories : PHP, MySQL, Databases, Date Time | | | Creates three SELECT form fields: Month, Day, and Year. You give it a string which will be used to make the name for the three fields, and a number of seconds to use as the default date. If you give it blank for this value, the current date is used. Categories : HTML and PHP, PHP, Date Time | | | If you want to create select buttons featuring current date this example will show you how... Categories : Date Time, HTML and PHP, PHP | | | Example of using the pcCalendar class, article 1468 on weberdev.com. Calendar example. Categories : PHP, Date Time, PHP Classes, Calendar | | | A PHP Calendar function with CSS : add a cool calendar to any php page by just adding a calendar class based function. Categories : PHP, PHP Classes, Calendar, Date Time | |
| | | | matthew waygood wrote : 1334
if [ $MONTH -ge 3 ] ; then
MONTH=`expr $MONTH - 2`
else
MONTH=`expr $MONTH + 10`
fi
if [ $MONTH -eq 11 ] || [ $MONTH -eq 12 ] ; then
YEAR=`expr $YEAR - 1`
fi
Can be re-written as:-
MONTH=`expr (($MONTH+9)%12)+1`;
| | | | matthew waygood wrote :1335
sorry not the year bit.
Very interesting bit of code, got me looking into Zeller a bit.
| |
|
|
|