Android Question day of week - a conflict

Discussion in 'Android Questions' started by drgottjr, Mar 27, 2015.

  1. drgottjr

    drgottjr Active Member Licensed User

    it's 1400h (new york time), march 27, 2015 as i write this. my device indicates a friday

    however, my app says march 27, 2015 is day 6. (per attached image)

    here's the code:
    Dim now As Long = DateTime.now
    Dim hour As Int = DateTime.GetHour(now) ' 0-23
    Dim day As Int = DateTime.GetDayOfWeek(now) ' 1-7 7=sunday

    Msgbox( DateTime.Date(now) & " hour = " & hour & " " & "day = " & day,"")


    i normally don't use datetime functions, and since the documentation says sunday is day 7, friday should be day 5. the msgbox output came as a surprise. how did i mess this up?

    -go
     

    Attached Files:

    • date.png
      date.png
      File size:
      175.5 KB
      Views:
      55
  2. NJDude

    NJDude Expert Licensed User

    Sunday is zero, so the code is correct, the documentation however, is another issue :D.
     
    lemonisdead likes this.
  3. keirS

    keirS Well-Known Member Licensed User

    Err no. Sunday is 1. If Sunday was 0 then Friday would be 5.

    0= Sunday
    1=Monday
    2=Tuesday
    3=Wednesday
    4=Thursday
    5=Friday
    6=Saturday



    1= Sunday
    2=Monday
    3=Tuesday
    4=Wednesday
    5=Thursday
    6=Friday
    7=Saturday
     
    thedesolatesoul likes this.
  4. NJDude

    NJDude Expert Licensed User

    Ah yes!
     
  5. drgottjr

    drgottjr Active Member Licensed User

    i see. it looks like i'll have to wait until sunday and run the app again ...
    android calendar functions define days of week as 1 - 7 (regrettably, not saying which is which).

    for my purposes i just need to know when it's "friday". i expected 5, but 5, 6, whatever. app says friday = 6. in either case sunday doesn't appear to be 7. thanks, all (or both)

    -go
     
  6. Roger Daley

    Roger Daley Well-Known Member Licensed User

  7. drgottjr

    drgottjr Active Member Licensed User

    thanks. looks like it was remission until i revived it. my apologies. i can't wait until tomorrow (sunday). if the eu designed an os, 0, 1, 6 or 7 would all be acceptable for sunday; so let us give thanks.:)

    -go
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    Where do you see it?

    [​IMG]
     
  9. drgottjr

    drgottjr Active Member Licensed User

    nowhere, obviously. i've given up my driver's permit due to vision issues. time for programming to go, as well. sigh
     

    Attached Files:

    RandomCoder and Roger Daley like this.
  10. Erel

    Erel Administrator Staff Member Licensed User

    Sorry, this wasn't my intention. Increase the font size and keep on going...
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice