summaryrefslogtreecommitdiff
path: root/ConvertDate.S
diff options
context:
space:
mode:
Diffstat (limited to 'ConvertDate.S')
-rw-r--r--ConvertDate.S130
1 files changed, 130 insertions, 0 deletions
diff --git a/ConvertDate.S b/ConvertDate.S
new file mode 100644
index 0000000..bd0353a
--- /dev/null
+++ b/ConvertDate.S
@@ -0,0 +1,130 @@
+**************************************************************************
+** **
+** ConvertDate - DateStamp in Klartext umwandeln (wie CLI's DATE) **
+** Beispiel: "Wednesday 24-Dec-1986 06:15:42" **
+** **
+** Created: 14-Mar-89 CHW Last update: 25-Jun-89 **
+** **
+**************************************************************************
+** **
+** Parameter : A0.L : Zeiger auf struct DateStamp **
+** A1.L : Zeiger auf Ausgabepuffer (min. 32 Bytes) **
+** Resultat : - **
+** **
+**************************************************************************
+
+ IDNT ConvertDate
+ SECTION text,CODE
+
+ INCLUDE "dos/dos.i"
+
+
+ XREF _sprintf
+
+ XDEF @ConvertDate
+
+
+@ConvertDate: movem.l d1-d4/a0-a2,-(SP)
+
+ ; Tag berechnen
+
+ move.l (a0),d2 ; D2 : Tag
+ move.l d2,d0 ; Tag
+ addq.l #1,d2 ; ist halt so ...
+ moveq.l #0,d3 ; D3 : Monat
+ move.l #1978,d4 ; D4 : Jahr
+
+ divu #7,d0
+ swap d0 ; Tag MOD 7
+ mulu #10,d0 ; Index in Tabelle
+ lea DayName(PC),a2
+ adda.w d0,a2
+1$: move.b (a2)+,(a1)+ ; Wochentag ausgeben
+ bne.b 1$
+ move.b #' ',-1(a1)
+
+2$: lea MonthTab(PC),a2
+3$: moveq.l #0,d1
+ move.b (a2)+,d1 ; Anzahl Tage im nächsten Monat
+ bne.s 4$
+ addq.l #1,d4 ; INC Jahr
+ moveq.l #0,d3 ; Monat resetten
+ bra.s 2$ ; ---> nochmal
+4$:
+ cmpi.b #28,d1 ; Februar ?
+ bne.s 5$ ; nein --->
+ moveq.l #3,d0
+ and.l d4,d0 ; Schaltjahr ?
+ bne.s 5$ ; nein --->
+ addq.l #1,d1 ; sonst INC Monatstage
+5$:
+ cmp.l d1,d2 ; Mehr Tage als dieser Mt ?
+ ble.s 6$ ; nein --->
+ sub.l d1,d2
+ addq.l #1,d3 ; INC Monat
+ bra.s 3$ ; ---> loop
+6$:
+ move.l d2,d0 ; Tag
+ bsr out2 ; %02d ausgeben
+ move.b #'-',(a1)+
+
+ lsl.w #2,d3 ; *4 für Index
+ lea MonthName(PC,d3.w),a2
+7$: move.b (a2)+,(a1)+ ; Monatsname ausgeben
+ bne.b 7$
+ move.b #'-',-1(a1)
+
+ move.l d4,d0 ; Jahr
+ divu #100,d0
+ swap.w d0 ; modulo 100
+ bsr out2 ; %02d ausgeben
+ move.b #' ',(a1)+
+
+ ; Uhrzeit berechnen
+
+ move.l ds_Minute(a0),d0 ; D0 : Stunden
+ divu #60,d0
+ move.l d0,d1
+ swap d1 ; D1 : Minuten
+
+ bsr out2 ; Stunden ausgeben
+ move.b #':',(a1)+
+ move.w d1,d0
+ bsr out2 ; Minuten ausgeben
+ move.b #':',(a1)+
+
+ move.l ds_Tick(a0),d0
+ divu #50,d0
+ bsr out2 ; Sekunden ausgebemn
+ clr.b (a1)+ ; String abschliessen
+
+end: movem.l (SP)+,d1-d4/a0-a2
+ rts
+
+ ; D0 als 2-stellige Zahl ausgeben (00-59)
+
+out2: ext.l d0
+ divu #10,d0
+ add.w #'0',d0
+ move.b d0,(a1)+ ; Zehner
+ swap d0
+ add.w #'0',d0
+ move.b d0,(a1)+ ; Einer
+ rts
+
+
+MonthName: dc.b "Jan",0,"Feb",0,"Mar",0,"Apr",0
+ dc.b "May",0,"Jun",0,"Jul",0,"Aug",0
+ dc.b "Sep",0,"Oct",0,"Nov",0,"Dec",0
+
+DayName: dc.b "Sunday",0,0,0,0
+ dc.b "Monday",0,0,0,0
+ dc.b "Tuesday",0,0,0
+ dc.b "Wednesday",0
+ dc.b "Thursday",0,0
+ dc.b "Friday",0,0,0,0
+ dc.b "Saturday",0,0
+
+MonthTab: dc.b 31,28,31,30,31,30,31,31,30,31,30,31,0
+
+ END