Percent Date Calculations

This is how I calculated when I had been meditating 0.97% of the days of my life:

First using the Biolator, I subtracted 1946-06-01 (the day I was born) from 1975-08-27 (the day I started regular practice of TM) to find how many days old I was on then (10679).

1975-08-27 - 1946-06-01 = 10679

Then, starting with basic equation is:

tmPercent = tmDays / (initDays + tmDays)

where:

tmPercent = 0.0097 (that is 0.97%)
mDays = x (the days I had been meditating when I was meditating 0.97% of the days of my life)
initDays = 10679 (Initiation Days, how many days old I was when I started regular practice of TM).

I substituted the above values on a piece of paper and I found:

0.0097 = x / (10679 + x)
(10679 + x) * 0.0097 = x
(10679 * 0.0097) + (0.0097 * x) = x
x - (0.0097 * x) = 10679 * 0.0097
x * (1 - 0.0097) = 10679 * 0.0097
x = (10679 * 0.0097) / (1 - 0.0097)

Then I went back to the Biolator:

10679 * 0.0097 = 103.5863
1 - 0.0097 = 0.9903
103.5863 / 0.9903 = 104.600929
1975-08-27 + 105 = 1975-12-10

The QBasic Date Functions ...

After taking a 1 credit class in Basic at MCC during the fall of 1992, I devoted the winter intersession in developing two functions (then subroutines) that would allow me to replicate the date functions of the Biolator. These in turn allowed me to easily create tables with dates and percentages and other programs related TM effects.

The first function calculates the Absolute Date, (i.e. number of days since 0001-01-01 A.D.) from a Gregorian Date, (i.e. a regular date in the form of yyyy-mm-dd). The other does the opposite by finding out how many whole 400 year periods (which I gave the variable name "Epochs") it contains, then how many whole centuries remain, then how many whole 4 year periods (I used the term "Olympiads" that was also used by ancient historians), and how many whole years. "JDate" is the number of days since the beginning of the year.

The version below is the one I used for the development of JavaScript functions used in the M-Meter. They can be used for any A.D. date calculations.

emf


FUNCTION AbsDate& (GregorianDate$)

    yyyy = VAL(LEFT$(GregorianDate$, 4))
    mm = VAL(MID$(GregorianDate$, 6, 2))
    dd = VAL(RIGHT$(GregorianDate$, 2))

    IF (yyyy MOD 4 = 0 AND yyyy MOD 100 <> 0) OR (yyyy MOD 400 = 0) THEN
        LeapDay = 1
    ELSE
        LeapDay = 0
    END IF

    DIM EOM(12)                                       ' Days to End Of Month
    EOM(1) = 31: EOM(2) = 59: EOM(3) = 90: EOM(4) = 120
    EOM(5) = 151: EOM(6) = 181: EOM(7) = 212: EOM(8) = 243
    EOM(9) = 273: EOM(10) = 304: EOM(11) = 334: EOM(12) = 365

    IF mm < 3 THEN
        JulianDate = dd + EOM(mm - 1)
    ELSE
        JulianDate = dd + (EOM(mm - 1) + LeapDay)
    END IF

    y = yyyy - 1                                      ' in year 1: (Y*365)=0

    AbsDate& = (y * 365) + (y \ 4) - (y \ 100) + (y \ 400) + JulianDate

END FUNCTION '{AbsDate&}

FUNCTION GregDate$ (AbsoluteDate&)

    REM: 1 Epoch   =  4 Centuries + 1 day= 146097 days
    REM: 1 Century = 25 Olympiads - 1 day=  36524 days: Leap Century: + 1 day
    REM: 1 Olympiad=  4 Years     + 1 day=   1461 days
    REM: 1 Year    =                     =    365 days: Leap Year   : + 1 day

    RDays = AbsoluteDate& - 1                         ' Remaining days

    Epochs = RDays \ 146097: RDays = RDays MOD 146097

    Centuries = RDays \ 36524:
    IF Centuries < 4 THEN
        RDays = RDays MOD 36524
    ELSE 'Last day of the last (leap) century of an epoch.
        Centuries = 3: RDays = 36524
    END IF

    Olympiads = RDays \ 1461: RDays = RDays MOD 1461

    Years = RDays \ 365:
    IF Years < 4 THEN
        RDays = RDays MOD 365
    ELSE 'Last day of the last (leap) year of an olympiad.
        Years = 3: RDays = 365
    END IF

    yyyy = (Epochs * 400) + (Centuries * 100) + (Olympiads * 4) + Years + 1

    JulianDate = RDays + 1
    REM  So that 0001/01/01 won't be 0001/01/00.

    IF (yyyy MOD 4 = 0 AND yyyy MOD 100 <> 0) OR (yyyy MOD 400 = 0) THEN
        LeapDay = 1
    ELSE
        LeapDay = 0
    END IF

    DIM EOM(12)                                       ' days to End Of Month
    EOM(1) = 31: EOM(2) = 59: EOM(3) = 90: EOM(4) = 120
    EOM(5) = 151: EOM(6) = 181: EOM(7) = 212: EOM(8) = 243
    EOM(9) = 273: EOM(10) = 304: EOM(11) = 334: EOM(12) = 365

    IF JDate <= EOM(1) THEN
        mm = 1
    ELSE
        FOR i = 2 TO 12
            IF JulianDate <= (EOM(i) + LeapDay) THEN mm = i: EXIT FOR
        NEXT i
    END IF

    IF mm < 3 THEN
        dd = JulianDate - EOM(mm - 1)
    ELSE
        dd = JulianDate - (EOM(mm - 1) + LeapDay)
    END IF

    yyyy$ = LTRIM$(STR$(ABS(yyyy)))
    mm$ = LTRIM$(STR$(mm))
    dd$ = LTRIM$(STR$(dd))


    yyyy$ = STRING$(4 - LEN(yyyy$), 48) + yyyy$
    mm$ = STRING$(2 - LEN(mm$), 48) + mm$
    dd$ = STRING$(2 - LEN(dd$), 48) + dd$

    GregDate$ = yyyy$ + "-" + mm$ + "-" + dd$            ' Gregorian date

END FUNCTION '{GregDate$}

Back to the M-Meter Project

Valid HTML5! Valid CSS!