Code archives/Miscellaneous/Currentday Currenttime Currentyear
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
This works for BMX and BB, just a quick way to seperate month sate and year all in integer format | |||||
Function currentyear(date$=Currentdate()) Local tstr$,tyear tstr$ = Mid(date$,8,4) tstr$ = Trim(tstr$) tyear = Int(tstr$) Return tyear End Function Function currentday(date$=Currentdate()) Local tstr$,tday tstr$ = Mid(date$,1,2) tstr$ = Trim(tstr$) tday = Int(tstr$) Return tday End Function Function currentmonth(date$=Currentdate()) Local tstr$,tmonth tstr$ = Mid(date$,4,3) tstr$ = Trim(tstr$) Select tstr$ Case "Jan" tmonth = 01 Case "Feb" tmonth = 02 Case "Mar" tmonth = 03 Case "Apr" tmonth = 04 Case "May" tmonth = 05 Case "Jun" tmonth = 06 Case "Jul" tmonth = 07 Case "Aug" tmonth = 08 Case "Sep" tmonth = 09 Case "Oct" tmonth = 10 Case "Nov" tmonth = 11 Case "Dec" tmonth = 12 Default tmonth = 0 End Select Return tmonth End Function |
Comments
| ||
"Expression must be constant" error in blitz3d. |
| ||
Same with BlitzMax, default values must be constant. You can achieve the same result like this:Function currentyear( date$ = "" ) If date = "" Then date = CurrentDate() Local tstr$,tyear tstr$ = Mid(date$,8,4) tstr$ = Trim(tstr$) tyear = Int(tstr$) Return tyear End Function |
| ||
This is the function I use to return an integer month, because I'm too lazy to type in all those 'CASE' statements :) |
Code Archives Forum