|
BB2 C port
API reference: Blitz libraries in C and the shared code
|
Macros | |
| #define | __NOLIBBASE__ |
| #define | DOS_BASE_NAME dosbase |
| #define | DAYSINQUADYR (365 * 4 + 1) /* 4 year cycle */ |
| #define | DAYSP1978 (DAYSINQUADYR * 494 + 366 + 365) /* 0/0/0 to 1/1/78 */ |
Functions | |
| ULONG | date_c (struct Library *dosbase) |
| SystemDate: the system date as days since 1/1/1978. | |
| ULONG | datestr_c (LONG days) |
| Date$(days.l): days since 1/1/1978 as a date string. | |
| ULONG | calcdays_c (const UBYTE *s) |
| NumDays(date$): a date string as days since 1/1/1978. | |
| void | dateformat_c (UWORD f) |
| DateFormat 0|1: the string format of Date$ and NumDays. | |
| UWORD | days_c (void) |
| Days: the day of the month of the last Date$. | |
| UWORD | months_c (void) |
| Months: the month of the last Date$. | |
| UWORD | years_c (void) |
| Years: the year of the last Date$. | |
| ULONG | weekday_c (void) |
| WeekDay: the day of the week of the last Date$ (0 = Sunday). | |
| ULONG | hours_c (struct Library *dosbase) |
| Hours: get the system time, the hour of the day. | |
| ULONG | mins_c (void) |
| Mins: the minutes of the time of the last Hours call. | |
| ULONG | secs_c (void) |
| Secs: the seconds of the time of the last Hours call. | |
| static ULONG | divu32 (ULONG n, UWORD d, ULONG *rem) |
| static LONG | gregskips (LONG days) |
| static LONG | gregskips_year (UWORD year, int early) |
| static void | put2 (ULONG r) |
Variables | |
| static UWORD | dateformat |
| static ULONG | totday = DAYSP1978 |
| struct { | |
| UWORD day | |
| UWORD year | |
| UWORD month | |
| } | dym |
| struct { | |
| struct DateStamp stamp | |
| UWORD months [13] | |
| } | dt |
| #define __NOLIBBASE__ |
| #define DAYSP1978 (DAYSINQUADYR * 494 + 366 + 365) /* 0/0/0 to 1/1/78 */ |
| #define DOS_BASE_NAME dosbase |
| ULONG calcdays_c | ( | const UBYTE * | s | ) |
NumDays(date$): a date string as days since 1/1/1978.
_calcdays: "dd/mm/yyyy" (or mm/dd/yyyy after DateFormat 1). Day and month: 1 or 2 digits, year: up to 4 (ends at "/", at the end of the string or after 4 characters). "Digits" are not checked: every character counts as char-48. d1 is the field being read, later the year / 4; d2 the character, later the leap days; d3 and d4 hold the first and second field, after the EXG for mm/dd/yyyy the day and the month. Fixed (#122): ADDQ.l #1 / SUBQ.l #1 on the day count (the original's word operations had no carry/borrow: NumDays("31/12/1977") = 65535). Fixed (#123): an empty field (a "/" as its first character) gives 0; the original took the "/" as the value 47. Fixed (#124): a month outside 1-12 gives 0 (the original indexed the month table with it: month 0 read the low word of the tick count of the last DateStamp, 13 the end mark, 14 and up the memory behind). Fixed (#125): the year ends at the end of the string too, an empty year gives 0 (the original read a short year on past the end). Fixed (#1029): a day or month field that ends at the end of the string gives 0 (the original read the 0 byte as a digit and the bytes behind it: NumDays("") or NumDays("1") parsed on into the memory behind the string when a "/" followed). Fixed (#1001): the days of the cycles are corrected by the century leap days the Gregorian calendar does not have (gregskips_year); the original's NumDays("1/3/2100") was one day too high.
| s | d0: the date string |
| ULONG date_c | ( | struct Library * | dosbase | ) |
SystemDate: the system date as days since 1/1/1978.
_date: JSR _DateStamp(a6) into the library's DateStamp.
| dosbase | a6: dos.library |
| void dateformat_c | ( | UWORD | f | ) |
DateFormat 0|1: the string format of Date$ and NumDays.
_dateformat: MOVE d0,dateformat.
| f | d0.w: 0 = dd/mm/yyyy, otherwise mm/dd/yyyy |
| ULONG datestr_c | ( | LONG | days | ) |
Date$(days.l): days since 1/1/1978 as a date string.
_datestr: "dd/mm/yyyy" (or mm/dd/yyyy after DateFormat 1) at a3; keeps day, year and month for Days, Years, Months and the day count for WeekDay. Dates are counted from day 0 = 1/1/0000 in 4 year cycles of 1461 days. d1 holds the 4 year cycles first, d2 the days of the cycles; for mm/dd/yyyy day and month are exchanged (EXG) before the output. Values outside 0..99 per two digits give other characters. Fixed (#120): day 366 of a cycle (1/1 of the year after a leap year, e.g. 1/1/1981) is the first day of the next year; the original showed it as 32/12 of the leap year (CMP #366: BLE instead of BLT). Fixed (#1001): the day count of the cycles is corrected by the century leap days the Gregorian calendar does not have (gregskips): the date is Gregorian (the original showed 29/2/2100 for 1/3/2100). WeekDay keeps the uncorrected count (the weekday follows from the days alone).
| days | d0: the days since 1/1/1978 |
| UWORD days_c | ( | void | ) |
Days: the day of the month of the last Date$.
|
static |
|
static |
|
static |
| ULONG hours_c | ( | struct Library * | dosbase | ) |
Hours: get the system time, the hour of the day.
_hours: JSR _DateStamp(a6) into the library's DateStamp (also for Mins and Secs), then minutes / 60 (DIVU).
| dosbase | a6: dos.library |
| ULONG mins_c | ( | void | ) |
Mins: the minutes of the time of the last Hours call.
_mins: of the last DateStamp (no DateStamp of its own; documented, not a bug): minutes / 60, SWAP.
| UWORD months_c | ( | void | ) |
Months: the month of the last Date$.
|
static |
| ULONG secs_c | ( | void | ) |
Secs: the seconds of the time of the last Hours call.
_secs: of the last DateStamp (no DateStamp of its own): ticks / 50.
| ULONG weekday_c | ( | void | ) |
WeekDay: the day of the week of the last Date$ (0 = Sunday).
Fixed (#121): SUBQ.l #2 on the day count; the original's SUBQ.w had no borrow from the high word (the weekday 2 too large when the low word of the count is 0 or 1).
| UWORD years_c | ( | void | ) |
Years: the year of the last Date$.
|
static |
| UWORD day |
| struct { ... } dt |
| struct { ... } dym |
| UWORD month |
| UWORD months[13] |
| struct DateStamp stamp |
|
static |
| UWORD year |