Holiday Smarts, U.S.

Share your advanced PureBasic knowledge/code with the community.
LJ
Enthusiast
Enthusiast
Posts: 177
Joined: Wed Apr 30, 2003 4:00 pm

Holiday Smarts, U.S.

Post by LJ »

The Purebasic HELP file on FormatDate reads:

Code: Select all

FormatDate()

Syntax

Text$ = FormatDate(Mask$, Date) 
Description

Returns a string representation of the Date, according to the specified Mask$. The Mask$ is a string which tells how the date should be formatted. The Mask$ accepts several reserved tokens: 
  %yyyy: Will be replaced by the year value, on 4 digits. 
  %yy: Will be replaced by the year value, on 2 digits. 
  %mm: Will be replaced by the month value, on 2 digits. 
  %dd: Will be replaced by the day value, on 2 digits.
How many times have you used a program that popped up a nice holiday message? You can very easily add this functionality to your program. Remember, this works only for hard coded date holidays (holidays that are on a specific date as opposed to "third Thursday" of the month).

Code: Select all

Date$ = FormatDate("%mm/%dd", Date())

If date$="01/01"
MessageRequester("Title", "Happy New Year!", 0)
EndIf

If date$="02/14"
MessageRequester("Title", "Happy Valentines Day!", 0)
EndIf

If date$="03/17"
MessageRequester("Title", "Happy St. Patricks Day!", 0)
EndIf

If date$="07/04"
MessageRequester("Title", "Happy 4th of July!", 0)
EndIf

If date$="11/11"
MessageRequester("Title", "Happy Veterans Day", 0)
EndIf

If date$="12/25"
MessageRequester("Title", "Merry Christmas", 0)
EndIf

Last edited by LJ on Sat Jul 12, 2003 9:23 pm, edited 1 time in total.
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

why "Left(date$,5)"?

date$ should be enought.
LJ
Enthusiast
Enthusiast
Posts: 177
Joined: Wed Apr 30, 2003 4:00 pm

Yes

Post by LJ »

Code corrected.
Post Reply