heitml Takes the World Wide Web to a Higher Level!
(Give us your Email Address to receive the latest heitml news)

Introduction
heitml Features
Language Guide
Language Reference
       

The heitml Libraries

   Standard Layout
   Session Libraries
   The dba Library
   Query Forms
   Scroller
   Outline Library
   Email Form Library
   Counter Library
   HTML Extensions
   Date/Time Library
   Math Library
   String Library
   Registered Apps
       
Supported Platforms
User Guide
Download
User Registration
Discussion Group
Mailinglist
       
NEW!
heitml 1.2 new features


Send us mail

Contact Info

   

Date and Time Functions
by Michael Elbel

Generic Functions

All functions come in versions with and without $ at the end of the name. Versions without $ return an integer, those with $ return a string that is padded to 2 digits (with a possible leading zero). They take an optional argument that defaults to SrvDate or SrvTime.

Name Arg Returns Example Output
year() date integer <? year()> 1997
<? year(18040229)> 1804
year$() date char <? year$()> 1997
<? year$(18040229)> 1804
year2() date integer <? year2()> 97
<? year2(18040229)> 4
year2$() date char <? year2$()> 97
<? year2$(18040229)> 04
month() date integer <? month()> 8
<? month(18040229)> 2
month$() date char <? month$()> 08
<? month$(18040229)> 02
day() date integer <? day()> 20
<? day(18040205)> 5
day$() date char <? day$()> 20
<? day$(18040205)> 05
hour() time char <? hour()> 16
<? hour(40807000)> 4
hour$() time char <? hour$()> 16
<? hour$(40807000)> 04
minute() time char <? minute()> 0
<? minute(40807000)> 8
minute$() time char <? minute$()> 00
<? minute$(40807000)> 08
sec() time char <? sec()> 57
<? sec(40807000)> 7
sec$() time char <? sec$()> 57
<? sec$(40807000)> 07


Date Conversion and Arithmetic Functions

These Functions perform conversion, checking and arithmetic on Dates. They are restricted to the range from 1582/10/15 (Beginning of the Gregorian calender to 9999/12/31.

Name Args Example Output
Is the given year a leap year?
leap() year <? leap(1996)> true
<? leap(1900)> false
The number of days since the start of the Gregorian
calendar range, 1582/10/15.
For invalid dates -1 is returned and gl.errno set
to a text describing the error.
daynumm() year,
month,
day
<? daynum(1996, 2, 29)> 150982
The same as above, but for a regular date.
The argument defaults to SrvDate.
daynum() date <? daynum()> 151520
<? daynum(19000228)> 115918
Day of the week for a given date.
Starts on Monday with 0.
weekdaym() year,
month,
day
<? weekdaym(1996, 2, 29)> 3
weekday() date <? weekday()> 2
<? weekday(19000228)> 2
Day of the year for a given date. Jan 1 is 1.
yeardaym() year,
month,
day
<? yeardaym(1996, 2, 29)> 60
yearday() date <? yearday()> 232
<? yearday(19000228)> 59
Week of the year for a given date according
to the ISO standard.
yearweekm() year,
month,
day
<? yearweekm(1996, 2, 29)> 9
yearweek() date <? yearweek()> 34
<? yearweek(19000228)> 9
Calculate the date of a given year,
yearday combination.
yeardaydate() year,
yearday
<? yeardaydate(1996, 59)> 19960229
Calculate the date of a given calendar daynum.
This is the inverse of daynum()
daynumate() daynum <? daynumate(150982)> 19960229
Add a number of days to a certain date
(to subtract use a negative number)
dateadd() date,
num
<? dateadd(19960201, -35)> 19951228
Return the number of days between two given dates
datesub() date1,
date2
<? datesub(19960307, 19960201)> 35
Calculate a numeric date from day, month and year (optional)
with sanity checking. If not specified, year will be set to
the current or the next year. The next year will be used if
the date is earlier than the current date. Two digit yearnums
will be expanded into the 1900 and 2000 range.
Yearnums <20 will be assumed to fall into the 2000 range.
date() day,
month,
year
<? date(29, 2, 1804)> 18040229
<? date(20, 2, 84)> 19840220
<? date(29, 2, 85)> -1
<? date(20, 2, 04)> 20040220
<? date(23, 8)> 19970823
<? date(17, 8)> 19980817
Calculate a time from hour, min and sec (optional, defaults to 0)
time() hour,
min,
sec
<? time(11, 58, 34)> 115834000
<? time(11, 55)> 115500000


Date and Time Text Output Functions and Tags

The following functions and tags perform date and time output tasks. They act language sensitive. Depending on the variable "gl.lang", different date output formats are chosen. Right now the two languages "en" and "de" are implemented, defaulting to "en". If gl.lang is not set, the package will initialize it to "en". The arguments default to SrvDate and SrvTime respectively. Printing the German results, one should remember to use the html formatting argument to the "?" tag to get umlauts printed properly.

Functions Returning Text Formats for Months, Weekdays, Date and Time

Example Output
monthname$()
<? monthname$()> August
<? monthname$(19000528)> May
<let gl.lang="de">
<? monthname$()> html;
August
monthnameshort$()
<? monthnameshort$()> Aug
<? monthnameshort$(15930309)> Mar
<let gl.lang="de">
<? monthnameshort$(15930309) html>
Mär
dayname$()
<? dayname$()> Wednesday
<? dayname$(15930309)> Tuesday
<let gl.lang="de">
<? dayname$(15930309) html>
Dienstag
daynameshort$()
<? daynameshort$()> Wed
<? daynameshort$(20000101)> Sat
<let gl.lang="de">
<? daynameshort$(20000101) html>
Sa
tdate$()
<? tdate$()> Wednesday August 20 1997
<? tdate$(20000101)> Saturday January 01 2000
<let gl.lang="de">
<? tdate$(20000101) html>
Samstag, 01. Januar 2000
tdate2$()
<? tdate2$()> Wed Aug 20 97
<? tdate2$(19891003)> Tue Oct 03 89
<let gl.lang="de">
<? tdate2$(19891003) html>
Di, 03. Okt. 89
date$()
<? date$()> 1997/08/20
<? date$(20000101)> 2000/01/01
<let gl.lang="de">
<? date$(20000101) html>
01.01.2000
date2$()
<? date2$()> 97/08/20
<? date2$(19891003)> 89/10/03
<let gl.lang="de">
<? date2$(19891003) html>
03.10.89
time$()
<? time$()> 16:00:57
<? time$(115959000)> 11:59:59

Convenience Tags for Date and Time Output

Name Arg Example Output
prtdate date <prtdate> Wednesday August 20 1997
<prtdate 20000101> Saturday January 01 2000
<let gl.lang="de">
<prtdate 20000101>
Samstag, 01. Januar 2000
prtdate2 date <prtdate2> Wed Aug 20 97
<prtdate2 19891003> Tue Oct 03 89
<let gl.lang="de">
<prtdate2 19891003>
Di, 03. Okt. 89
prdate date <prdate> 1997/08/20
<prdate 20000101> 2000/01/01
<let gl.lang="de">
<prdate 20000101>
01.01.2000
prdate2 date <prdate2> 97/08/20
<prdate2 19891003> 89/10/03
<let gl.lang="de">
<prdate2 19891003>
03.10.89
prtime time <prtime> 01:99:70
<prtime 115959000> 11:59:59


Calendar Tags

Finally, we have written some tags that allow you to display formatted calendars within your heitml Applications. They all follow the setting of gl.lang. The base functionality is delivered by the <cal> tag. It displays a single month in calendar form like this:

August 1997
W.Mon Tue Wed Thu Fri Sat Sun
31 123
3245678910
3311121314151617
3418192021222324
3525262728293031

The <cal> tag takes up to 8 arguments:

m:
The month the calender shall be displayed for. Defaults to month()
y:
The year the calender shall be displayed for. Defaults to year()
dmark, mmark:
The month and a day of the month that shall be marked (e.g. to show the current date)
wcol, sacol, sucol and mcol:
The text colors to use for yearweek, saturday, sunday and the marked day

To show how to use this, there are two additional tags,
<threemcal m=month() y=year() column=true> and
<yearcal y=year() cols=3 url="" >.

<threemcal> displays a three month calendar centered around the given month (or the current one). The current day is marked. You can choose between two layouts, the months in a row and in a column.

July 1997
W.Mon Tue Wed Thu Fri Sat Sun
27 123456
2878910111213
2914151617181920
3021222324252627
3128293031 
August 1997
W.Mon Tue Wed Thu Fri Sat Sun
31 123
3245678910
3311121314151617
3418192021222324
3525262728293031
September 1997
W.Mon Tue Wed Thu Fri Sat Sun
361234567
37891011121314
3815161718192021
3922232425262728
402930 

<threemcal> displays a year calendar for the given year in the specified number of columns. You can supply it with a url and it will generate a header that allows you to click forward and backward within years. Have a look at http://www.ditec.de/dis/calendar.hei for an example.


This page was dynamically generated by heitml
© 1996-1997 H.E.I. All Rights Reserved


heitml documentation (c) 1997 H.E.I. GmbH Mannheim, Germany