Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
StopWatch Timer
Robin Hood Xtra
Amara Flash News Ticker
New bitmap from existing member
Direct TTS (Text to speech)
Open Windows Explorer
Help Wizard
Cells Xtra
Simple Sprite Mover Behavior
Indeo Video
 

 

 

Behavior getNameOfDate

Added on 5/14/2002

 

Compatibilities:
D7 D8 D8_5 Script Shockwave

This item has not yet been rated

Author: mango

returns the name of day or month in chosen language

--usage getNameOfDate
--returns the name of day or month in chosen language

--getDate(theDate, request, language, abb)
--theDate, required. Must be of type date and must be of after date(1900,01,01)
--request, required. Must be either #day or #month (symbol)
--language, optional. Should be a string. Add your own in the case statement within the handler
--Language will default to English
--abb, optional. Makes the returned string to be of three chars length

--errorcodes
-- -1 = request is not of type #symbol.
-- -2 = theDate is not of type #date
-- -3 = theDate is pre 1900
-- -4 = request values is other than #day and #month

--example:
--put getNameOfDate(the systemdate,#day,"se")
-- "Onsdag"
--put getNameOfDate(the systemdate,#month)
-- "May"
--put "You were born on a" && getnameofdate(date(1992,07,13),#day)
-- "You were born on a Monday"

on getNameOfDate theDate, request, language, abb
  if symbolP(request) then
    if ilk(theDate) = #date then
      if not (ilk(abb) = #integer or ilk(abb) = #void) then abb = 0
      case language of
        "se":
          days = ["Måndag", "Tisdag", "Onsdag", "Torsdag", "Fredag", "Lördag", "Söndag"]
          months = ["Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September", "Oktober", "November", "December"]          
        otherwise
          days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
          months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]          
      end case
      tDate = [:]
      refDate=date(1900,1,1)
      if theDate - refDate < 0 then return -3
      currentDayNum = ((theDate - refDate) mod 7) +1
      currentDay = days[currentDayNum]
      if abb then currentDay = currentDay.char[1..3]
      tDate.addProp(#day, currentDay)
      currentMonth = months[theDate.month]
      if abb then currentMonth = currentMonth.char[1..3]
      tDate.addProp(#month, currentMonth)
      if voidp(tdate[request]) then return -4
      return tDate[request]
    else
      return -2
    end if
  else
    return -1
  end if
end

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail