Searching \ for 'How to get day of week given today's date?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/index.htm?key=how+get+day+week
Search entire site for: 'How to get day of week given today's date?'.

Truncated match.
PICList Thread
'How to get day of week given today's date?'
1996\11\27@010017 by Brooke

flavicon
face
Hi:

I am working on a GPS based clock and would like to display the
day of the week (Sun, Mon,....) I know the day, month, and year.
Does anyone have PIC code for this?

Thanks,
Brooke

PS the LCD info at:
www.iaehv.nl/users/pouweha/lcd2.htm#PIC_example
worked the first time used.  Thanks Peter Ouwehand!

1996\11\27@022252 by fastfwd

face
flavicon
face
Brooke <spam_OUTPICLISTTakeThisOuTspamMITVMA.MIT.EDU> wrote:

> I am working on a GPS based clock and would like to display the
> day of the week (Sun, Mon,....) I know the day, month, and year.
> Does anyone have PIC code for this?

   Brooke:

   If your application is non-commercial (i.e., you're not selling
   your GPS clock), feel free to use the following:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;                                                         ;
; DAY-OF-THE-WEEK CALCULATOR, WRITTEN BY ANDREW WARREN.   ;
;                                                         ;
; (C) 1995 FAST FORWARD ENGINEERING                       ;
;                                                         ;
; PERMISSION IS HEREBY GRANTED FOR ALL NON-COMMERCIAL USE ;
; SO LONG AS THIS NOTICE IS RETAINED IN IN ITS ENTIRETY.  ;
;                                                         ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; FOR ANY DATE BETWEEN JANUARY 1 1995 AND DECEMBER 31 1994,
; CALCULATE THE DAY OF THE WEEK [0=SUNDAY, 1 = MONDAY,
; .... 6 = SATURDAY].
;
; ENTER WITH MONTH [1-12] IN "MONTH", DAY-OF-MONTH [1-X]
; IN "DAY", AND YEAR [95-99, 00-94] IN "YEAR".  IF "YEAR"
; IS LESS THAN 95, THIS SUBROUTINE ASSUMES THAT WE'RE IN
; THE 21ST CENTURY.  OTHERWISE, IT ASSUMES THAT WE'RE IN
; THE 20TH.
;
; ON EXIT, DAY-OF-WEEK IS IN "DOW".  "DAY", "MONTH", AND
; "YEAR" ARE UNCHANGED.

DAYWEEK:

; THE FOLLOWING TWO LINES ARE ONLY NECESSARY IF YOU'RE
; USING A 14-BIT PIC (16C6X, 16C7X, 16C8X, ETC.).  FOR
; ALL OTHER PICS, JUST MAKE SURE THAT THE "MONTHTBL"
; SUBROUTINE IS ENTIRELY CONTAINED IN PAGE 0.

       MOVLW   HIGH MONTHTBL   ;MAKE SURE THE "ADDWF PCL"
       MOVWF   PCLATH          ;IN "MONTHTBL" WORKS.

       DECF    MONTH,W         ;W = MONTH - 1.
       CALL    MONTHTBL        ;LOOKUP THE D-O-W FOR THE
                               ;1ST OF THIS MONTH.

       MOVWF   DOW             ;STORE IT.

; AGAIN, THE FOLLOWING TWO LINES ARE ONLY NECESSARY FOR
; PARTS THAT USE "PCLATH".

       MOVLW   $+2             ;RESTORE PCLATH.
       MOVWF   PCLATH          ;

       MOVLW   3               ;MONTH >= MARCH?
       SUBWF   MONTH,W         ;
       BNC     NOLEAP          ;IF NOT, JUMP AHEAD.

       MOVLW   00000011B       ;OTHERWISE, IS THIS A
       ANDWF   YEAR,W          ;LEAP YEAR?

       BNZ     NOLEAP          ;IF NOT, JUMP AHEAD.

; IT'S MARCH 1ST OR LATER, AND THIS YEAR'S A LEAP YEAR.

       INCF    DOW             ;ADD A LEAP DAY.

NOLEAP:

       CLRC                    ;DOW = DOW + (YEAR-1)/4
       RLF     DOW             ;
       DECF    YEAR            ;    = 2*DOW + (YEAR-1)/2
       RLF     YEAR,W          ;      ------------------.
       RRF     YEAR,W          ;              2
       INCF    YEAR            ;
       ADDWF   DOW             ;
       CLRC                    ;
       RRF     DOW             ;

       MOVF    DAY,W           ;DOW = DOW + DAY + YEAR.
       ADDWF   YEAR,W          ;
       ADDWF   DOW             ;

       MOVLW   95              ;YEAR < 95?
       SUBWF   YEAR,W          ;
       SKPC                    ;IF NOT, SKIP AHEAD.

       DECF    DOW             ;OTHERWISE, DOW = DOW - 1.

       MOVLW   7               ;DOW = DOW MOD 7.
                               ;
       SUBWF   DOW             ;
       SKPNC                   ;
       GOTO    $-2             ;
                               ;
       ADDWF   DOW             ;

       RETURN                  ;RETURN.  IF YOU'RE USING
                               ;A 12-BIT PIC, MAKE THIS A
                               ;"RETLW 0" OR SOMETHING.

MONTHTBL:

       ADDWF   PCL

       DT      7,10,10,13      ;DAY-OF-WEEK FOR FIRST DAY
       DT      8,11,13,9       ;OF EACH MONTH (IN YEAR
       DT      12,7,10,12      ;1995). 7=SUNDAY, 8=MONDAY,
                               ;...., 13=SATURDAY.

Enjoy...

-Andy

=== Andrew Warren - .....fastfwdKILLspamspam@spam@ix.netcom.com                 ===
=== Fast Forward Engineering - Vista, California          ===
===                                                       ===
=== Custodian of the PICLIST Fund -- For more info, see:  ===
=== http://www.geocities.com/SiliconValley/2499/fund.html ===

1996\11\27@095330 by rrasa

flavicon
face
> I am working on a GPS based clock and would like to display the
> day of the week (Sun, Mon,....) I know the day, month, and year.
> Does anyone have PIC code for this?

//
// Return day of week (0-6, 0 = Sunday) given
// year (1600-), month (1-12), and day (1-31):
//
int GetDayOfWeek(int Year, int Month, int Day)
{
   if (Month <= 2) {
       Year -= 1;
       Month += 12;
   }
   return (6 + Day + ((13 * (Month + 1)) / 5) + Year +
           (Year / 4) - (Year / 100) + (Year / 400)) % 7;
}

If you want to convert that to a string, just use the number this
returns as an offset into a table of strings ...

Randy Rasa
rrasaspamKILLspamsky.net
http://www.sky.net/~rrasa

1996\11\27@121513 by Peer Ouwehand

flavicon
face
At 21:57 96/11/26 -0800, you wrote:
>Hi:
>
>I am working on a GPS based clock and would like to display the
>day of the week (Sun, Mon,....) I know the day, month, and year.
>Does anyone have PIC code for this?
>
>Thanks,
>Brooke
>
>PS the LCD info at:
>www.iaehv.nl/users/pouweha/lcd2.htm#PIC_example
>worked the first time used.  Thanks Peter Ouwehand!
>

You'r welcome...

<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
   Peer Ouwehand
   .....pouwehaKILLspamspam.....iaehv.nl
   http://www.iaehv.nl/users/pouweha/

   Wanna chat... try me on PowWow.

   Welcome my son, welcome to the machine. (Pink Floyd)
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

1996\11\27@141406 by Wolfram Liebchen
flavicon
face
At 23:28 26.11.96 -0800, you wrote:
>; DAY-OF-THE-WEEK CALCULATOR, WRITTEN BY ANDREW WARREN.   ;

>; FOR ANY DATE BETWEEN JANUARY 1 1995 AND DECEMBER 31 1994,
>
>-Andy

What?

Does it mean, this routine will never work?

Wolfram



+-----------------------------------------------------+
| Wolfram Liebchen                                    |
| Forschungsinstitut fŸr Optik, TŸbingen, Deutschland |
| EraseMEliebchenspam_OUTspamTakeThisOuTffo.fgan.de                         |
+-----------------------------------------------------+

1996\11\27@165625 by fastfwd

face
flavicon
face
I wrote, in the comments for the day-of-the-week calculator I posted
here yesterday:

> ; FOR ANY DATE BETWEEN JANUARY 1 1995 AND DECEMBER 31 1994

... and Wolfram Liebchen commented:

> What?
>
> Does it mean, this routine will never work?

   Wolfram:

   No... It only means that I shouldn't send e-mail after 11 pm.

   The comment should have read:  "between January 1 1995 and
   December 31 2094".

   -Andy

=== Andrew Warren - fastfwdspamspam_OUTix.netcom.com                 ===
=== Fast Forward Engineering - Vista, California          ===
===                                                       ===
=== Custodian of the PICLIST Fund -- For more info, see:  ===
=== http://www.geocities.com/SiliconValley/2499/fund.html ===

1996\11\27@182822 by Gonzalo Palarea

flavicon
I think he meant between jan 1 1995 and dec 31 1999 (or?)

At 08:15 PM 11/27/96 +0100, you wrote:
{Quote hidden}

More... (looser matching)
- Last day of these posts
- In 1996 , 1997 only
- Today
- New search...