Time for action – creating date and time pickers

Let's make another test-rig stack, which we'll use to try out some date and time pickers:

  1. Create a new Mainstack, name it ReminderFunctions, and save the stack.
  2. Add two fields and two new buttons.
  3. Name one field dateinseconds and the other timeinseconds.
  4. Name the buttons as Pick Date and Pick Time.
  5. Set the script of the Pick Date button to this:
    on mouseUp
      mobilePickDate date
      put the result into tDate
      convert tDate to seconds
      put tDate into field "dateinseconds"
    end mouseUp
  6. Set the Pick Time button script to this:
    on mouseUp
      mobilePickDate "time"
      put the result into tTime
      convert tTime to seconds
      put tTime into field timeinseconds
    end mouseUp
  7. Set the Standalone Application Settings so that you can test on iOS or Android.
  8. Choose your Test Target (in the following steps, you can see that the iPhone simulator was chosen in this case) and do a Test.
  9. Click on the Pick Date button.
  10. Select December 25th, 2012 and click on Done.
  11. The number of seconds from midnight of January 1, 1970 to midnight of Christmas day 2012 will be shown in the first field that you created.
  12. Click on the Pick Time button and set the time to 1 am. The following image shows how the picker looks different on iOS and the Android simulator:
    Time for action – creating date and time pickers
  13. Click on Done and you will see the number of seconds from midnight of January 1 1970 to 1 AM of the day you do this test in the right-hand side field.

What just happened?

We just made two simple scripts that call the native date or time picker and convert the result into seconds to then show them in a field. What is interesting to note is that for the Pick Time case, it doesn't return the number of seconds of the current day, that is, all the seconds since midnight of January 1, 1970. In order to set a notification time for a particular time of a particular date, we have to do a little arithmetic. We'll go into that a little later when we make the actual reminder app in the Making the reminders app section of this chapter.

Pop quiz – OA (odd acronyms!)

You may have noticed that the acronym for "Coordinated Universal Time" is UTC and not CUT. Why is that?

  1. CUT is too common a word.
  2. So as not to upset the French.
  3. The acronym committee members were dyslexics.

Answer: 2

The French may not have proactively objected, but indeed, the acronym of UTC was chosen so as to not specifically match the English version of the phrase. It also fell in nicely with the other acronyms such as UT0, UT1, and so on.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.105.239