ymd


* S*BASIC Date routines
* YEAR%, MONTH%, DAY% and WEEKDAY%
*
* ©pjwitte 2oo6
*
* V0.01 September 27th 2006
*

        section code

        include dev8_keys_sbasic
        include dev8_keys_err

        xdef YEAR,MONTH,DAY,WEEKDAY

        xref ut_cal
        xref dtpar
        xref retint

*
YEAR
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Extract the year, given DATE
*
* V0.01 September 27th 2006
*
* yr% = YEAR%[(date)]
*

        bsr.s getdate

        move.w d6,d4
        bra retint


*
MONTH
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Extract the month (1..12), given DATE
*
* V0.01 September 27th 2006
*
* mnth% = MONTH%[(date)]
*

        bsr.s getdate

        addq.w #1,d4            convert 0..11 to 1..12
        bra retint

*
getdate
        bsr dtpar
        bne.s exit              return to basic

        subq.w #1,d3            one par or less?
        bmi ut_cal               zero => got timestamp

        bne.s err_ipar           some mistake..

        addq.l #4,a1            tidy stack
        move.l a1,sb_arthp(a6)

        bra ut_cal

err_ipar
        moveq #err.ipar,d0

exit
        addq.l #4,a7
        rts

*
DAY
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Extract the day of month (1..31), given DATE
*
* V0.01 September 27th 2006
*
* dm% = DAY%[(date)]
*

        bsr.s getdate

        move.w d1,d4
        bra retint


*
WEEKDAY
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Extract the day of the week (0..6), given DATE
*
* V0.01 September 27th 2006
*
* dw% = WEEKDAY%[(date)]
*

        bsr.s getdate

        swap d4
        bra retint

*
        end

Back to Index
HTML generated by the amazing asm2htm !
2006 Oct 01 00:36:25