Cute Date
Posted: Fri Apr 01, 2011 12:53 pm
Happy April Fools! Nope Cute Date is not someone to take to a movie or dinner... 
Anyway, it is a Date library for PB4.51 (32-bit-Windows) ASCII using quads.
Download it here http://hotfile.com/dl/123715849/d80e407/QuadDate.zip.html.
and
Copy "QuadDate" to C:\Program Files\PureBasic\PureLibraries\UserLibraries
Copy "QuadDate.res" to C:\Program Files\PureBasic\Residents
Copy "QuadDate.chm" to C:\Program Files\PureBasic\Help
Use it at your own risk. Below is the example file.

Anyway, it is a Date library for PB4.51 (32-bit-Windows) ASCII using quads.
Download it here http://hotfile.com/dl/123715849/d80e407/QuadDate.zip.html.
and
Copy "QuadDate" to C:\Program Files\PureBasic\PureLibraries\UserLibraries
Copy "QuadDate.res" to C:\Program Files\PureBasic\Residents
Copy "QuadDate.chm" to C:\Program Files\PureBasic\Help
Use it at your own risk. Below is the example file.
Code: Select all
mydate.q = QDate()
myyear.q = QDateOnly(2008)
;Debug GetQDateMask()
;Debug FormatQDate(mydate)
;Debug FormatQDate(myyear)
;Debug FormatQDate(myyear, "%dd/%mm/%yyyy")
OpenWindow(0, 10, 10, 600, 400, "Cute Date")
X = 20
Y = 20
W = 100
H = 20
A = 150
G = 30
dg1 = DateGadget(#PB_Any, X, Y, W, H, "%dd/%mm/%yyyy")
SetGadgetQDate(dg1, mydate)
tg1 = StringGadget(#PB_Any, X + A, Y, W * 2, H, "")
Y = Y + G
dg2 = DateGadget(#PB_Any, X, Y, W, H, "%dd-%mm-%yyyy")
SetGadgetQDate(dg2, myyear)
tg2 = StringGadget(#PB_Any, X + A, Y, W * 2, H, "")
def_day$ = GetQDateDays()
def_month$ = GetQDateMonths()
def_time$ = GetQDateMeridiem()
def_mask$ = GetQDateMask()
Y = Y + G + G
sg1 = StringGadget(#PB_Any, X, Y, W, H, "")
tg3 = StringGadget(#PB_Any, X + A, Y, W * 2, H, def_mask$)
SetGadgetColor(tg3, #PB_Gadget_BackColor, #Yellow)
Y = Y + G
sg2 = StringGadget(#PB_Any, X, Y, W, H, "")
tg4 = StringGadget(#PB_Any, X + A, Y, W * 2, H, "")
Y = Y + G
sg3 = StringGadget(#PB_Any, X, Y, W, H, "")
tg5 = StringGadget(#PB_Any, X + A, Y, W * 2, H, "")
Y = Y + G
sg4 = StringGadget(#PB_Any, X, Y, W, H, "")
tg6 = StringGadget(#PB_Any, X + A, Y, W * 2, H, "")
Y = Y + G
sg5 = StringGadget(#PB_Any, X, Y, W, H, "")
tg7 = StringGadget(#PB_Any, X + A, Y, W * 2, H, "")
Y = Y + G
sg6 = StringGadget(#PB_Any, X, Y, W, H, "")
X = 450
Y = 20
W = 80
H = 20
bdefault = ButtonGadget(#PB_Any, X, Y, W, H, "Default")
Y = Y + G
bmalay = ButtonGadget(#PB_Any, X, Y, W, H, "Malay")
r = #True
While r
e = WaitWindowEvent()
Select e
Case #PB_Event_Gadget
Select EventGadget()
Case bdefault
SetQDateDays(def_day$)
SetQDateMonths(def_month$)
SetQDateMeridiem(def_time$)
Case bmalay
SetQDateDays("Ahad,Isnin,Selasa,Rabu,Khamis,Jumaat,Sabtu")
SetQDateMonths("Januari,Februari,Mac,April,Mei,Jun,Julai,Ogos,September,Oktober,November,Disember")
SetQDateMeridiem("pagi,petang")
EndSelect
mydate = GetGadgetQDate(dg1)
myyear = GetGadgetQDate(dg2)
SetQDateMask(GetGadgetText(tg3))
;Debug mydate
;Debug myyear
;
; additional format flags
; day names %aaa (first 3 chars), %aaaa (full)
; month names %mmm (first 3 chars), %mmmm (full)
; am/pm %pm
;
SetGadgetText(tg1, FormatQDate(mydate, "%aaaa, %mmmm %dd %yyyy, %hh:%ii:%ss %ap"))
SetGadgetText(tg2, FormatQDate(myyear, "%dd %mmm %yyyy %hh:%ii:%ss"))
SetGadgetText(sg1, "Year : " + Str(QDateDiff(mydate, myyear, #QDATE_TYPE_YEAR)))
SetGadgetText(sg2, "Month: " + Str(QDateDiff(mydate, myyear, #QDATE_TYPE_MONTH)))
SetGadgetText(sg3, "Day : " + Str(QDateDiff(mydate, myyear, #QDATE_TYPE_DAY)))
SetGadgetText(sg4, "Hour : " + Str(QDateDiff(mydate, myyear, #QDATE_TYPE_HOUR)))
SetGadgetText(sg5, "Min : " + Str(QDateDiff(mydate, myyear, #QDATE_TYPE_MINUTE)))
SetGadgetText(sg6, "Sec : " + Str(QDateDiff(mydate, myyear, #QDATE_TYPE_SECOND)))
SetGadgetText(tg4, FormatQDate(mydate))
SetGadgetText(tg5, "Next Year: " + FormatQDate(QDateAdd(mydate, 1, #QDATE_TYPE_YEAR)))
SetGadgetText(tg6, "Prev Month: " + FormatQDate(QDateAdd(mydate, -1, #QDATE_TYPE_MONTH)))
SetGadgetText(tg7, Str(QDay(mydate)) + " " + Str(QMonth(mydate)) + " " + Str(QYear(mydate)) + " " + Str(QHour(mydate)) + " " + Str(QMinute(mydate)) + " " + Str(QSecond(mydate)) + " " + Str(QDOW(mydate)) + " " + Str(QDaysToYear(mydate)))
Case #PB_Event_CloseWindow
r = #False
EndSelect
Wend
End