Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Get list of future dates?
Forum Updated to NodeBB v4.3 + New Features

Get list of future dates?

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 3 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cmer4
    wrote on last edited by
    #1

    Hi all,

    Not sure I am getting any documentation covering this: how can one get future dates in QML?
    I tried to use javascript - not getting me anywhere (see below). it just adds to date string digit "1"...

    Either I am missing something but I always thought as easy task as this can't be SO complicated;(((
    @
    function populatefuturedates() {
    var today = new Date()
    var tomorrow = today+1
    }
    @
    [edit, code tags added, koahnig]

    1 Reply Last reply
    0
    • C Offline
      C Offline
      cmer4
      wrote on last edited by
      #2

      Also tried this below and found that for the current Date() if attempted to get month number it gives me 7 instead of 8...how come??

      @function populatemydates() {
      var day0 = new Date()
      var day0month = day0.getMonth()
      var day1 = new Date(day0.getTime()+86400000)
      var day2 = new Date(day1.getTime()+86400000)
      var day3 = new Date(day2.getTime()+86400000)
      var day4 = new Date(day3.getTime()+86400000)
      var day5 = new Date(day4.getTime()+86400000)
      console.log(day0month)
      }@

      1 Reply Last reply
      0
      • C Offline
        C Offline
        cmer4
        wrote on last edited by
        #3

        "Ok seems like 7 is august;)":http://www.w3schools.com/jsref/jsref_getmonth.asp

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sidewinder
          wrote on last edited by
          #4

          Try looking at Javascript documentation: "Date Object":http://www.w3schools.com/jsref/jsref_obj_date.asp.
          getMonth() returns value from 0 to 11 so 7 is august.

          edit: too late :)

          "Never memorize what you can look up in books."
          Albert Einstein

          1 Reply Last reply
          0
          • C Offline
            C Offline
            chriadam
            wrote on last edited by
            #5

            In JavaScript, the Date object is just a number, which is interpreted as having some particular meaning. Read the ecma262r5 spec for the exact semantics, but I believe that it's the number of milliseconds since some epoch. Whenever you do something like "someObject + 1" the JavaScript engine will say: "can I convert the someObject to a primitive value, to which the +1 operation makes sense?" -- and for Date, the answer is yes (actually, for all objects the answer is yes, although in some cases it's rather arbitrary as to whether you get a string back or a number) - since internally it really is just a number.

            If you are writing JavaScript code in QML, it does help to have the ECMA262r5 specification on hand.

            Cheers,
            Chris.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved