From 1c84bc563683ed0e8d866b6dee6f5dde23107c82 Mon Sep 17 00:00:00 2001 From: Adam Szczerbiak Date: Thu, 28 Jan 2016 12:41:53 +0100 Subject: [PATCH] Reinforced modules with example methods call. Change-Id: Ice7475268425dde1aa0e45c23205a5cb9aea9aaa Signed-off-by: Adam Szczerbiak --- .../html/device_api/mobile/tizen/badge.html | 56 ++- .../html/device_api/mobile/tizen/contact.html | 316 +++++++++++++-- .../html/device_api/mobile/tizen/time.html | 433 ++++++++++++++++++++- .../html/device_api/mobile/tizen/tizen.html | 42 ++ 4 files changed, 802 insertions(+), 45 deletions(-) diff --git a/org.tizen.web.apireference/html/device_api/mobile/tizen/badge.html b/org.tizen.web.apireference/html/device_api/mobile/tizen/badge.html index 6c4324a..82766d9 100644 --- a/org.tizen.web.apireference/html/device_api/mobile/tizen/badge.html +++ b/org.tizen.web.apireference/html/device_api/mobile/tizen/badge.html @@ -114,6 +114,10 @@ There is a tizen.badge object that allows accessing the functionality of the Bad Since: 2.3

+
+

Code example:

   console.log("Maximum length of a badge number is " + tizen.badge.maxBadgeCount);
+ 
+
@@ -284,14 +288,18 @@ There is a tizen.badge object that allows accessing the functionality of the Bad
-

Code example:

  function watcher(appId, count) {
+

Code example:

  // Let's assume that at least two applications are installed
+
+  function onListInstalledApps(appsInfo) {
+    function watcher(appId, count) {
       console.log(appId + ' badge number were updated : ' + count);
+    }
+
+    // Registers to be notified when the badge number changes
+    tizen.badge.addChangeListener([appsInfo[0].id, [appsInfo[1].id], watcher);
   }
 
-  // Registers to be notified when the badge number changes
-  // Let's assume that applications "AVbg1ZHu6l.BadgeSample" and "BDb5tZJe47.TestSample"
-  // are installed
-  tizen.badge.addChangeListener(["AVbg1ZHu6l.BadgeSample", "BDb5tZJe47.TestSample"], watcher);
+  tizen.application.getAppsInfo(onListInstalledApps);
  
@@ -341,18 +349,21 @@ There is a tizen.badge object that allows accessing the functionality of the Bad
-

Code example:

  // Receives badge number changes
-  function watcher(appId, count) {
+

Code example:

  // Let's assume that at least two applications are installed
+
+  function onListInstalledApps(appsInfo) {
+    function watcher(appId, count) {
       console.log(appId + ' badge number were updated : ' + count);
-  }
+    }
 
-  // Registers to be notified when the badge number changes
-  // Let's assume that applications "AVbg1ZHu6l.BadgeSample" and "BDb5tZJe47.TestSample"
-  // are installed
-  tizen.badge.addChangeListener(["AVbg1ZHu6l.BadgeSample", "BDb5tZJe47.TestSample"], watcher);
+    // Registers to be notified when the badge number changes
+    tizen.badge.addChangeListener([appsInfo[0].id, [appsInfo[1].id], watcher);
 
-  // Cancels the watch operation
-  tizen.badge.removeChangeListener(["AVbg1ZHu6l.BadgeSample", "BDb5tZJe47.TestSample"]);
+    // Cancels the watch operation
+    tizen.badge.removeChangeListener([appsInfo[0].id, [appsInfo[1].id]);
+  }
+
+  tizen.application.getAppsInfo(onListInstalledApps);
  
@@ -401,6 +412,23 @@ There is a tizen.badge object that allows accessing the functionality of the Bad +
+

Code example:

   // logs the number of badge changes:
+   function watcher(appId, count) {
+     console.log(appId + ' -> badge number updates: ' + count);
+   }
+
+   // gets Application's ID:
+   var appId = tizen.application.getCurrentApplication().appInfo.id;
+
+   // let's assume that the application "TestSample.main" has been installed.
+   var targetAppId = "TestSample.main";
+
+   // registers to be notified when the badge number changes for either
+   // this or targetAppId application:
+   tizen.badge.addChangeListener([appId, targetAppId], watcher);
+ 
+
diff --git a/org.tizen.web.apireference/html/device_api/mobile/tizen/contact.html b/org.tizen.web.apireference/html/device_api/mobile/tizen/contact.html index 4d13efb..45394b6 100644 --- a/org.tizen.web.apireference/html/device_api/mobile/tizen/contact.html +++ b/org.tizen.web.apireference/html/device_api/mobile/tizen/contact.html @@ -3455,10 +3455,10 @@ The contact, this value is indicating, is used to show detailed information of t

Since: 2.0 -

+

  • - readonly + readonly long usageCount
    The number of contact usage.
    @@ -3795,6 +3795,42 @@ This dictionary is used to input parameters when contacts are created. } +
    +

    Code example:

     // Gets the default address book.
    + var addressbook = tizen.contact.getDefaultAddressBook();
    + var contact = null;
    + 
    + var name = new tizen.ContactName({
    +   firstName: "Forrest",
    +   lastName: "Gump"
    + });
    + var addresses = [ new tizen.ContactAddress({
    +                       city: "New York",
    +                       streetAddress: "46th St.",
    +                       isDefault: true }) ];
    + var phoneNumbers = [ new tizen.ContactPhoneNumber("(111) 555-1212"),
    +                      new tizen.ContactPhoneNumber("(111) 555-1213") ];
    + 
    + try {
    +   contact = new tizen.Contact({
    +     name: name,
    +     addresses: addresses,
    +     phoneNumbers: phoneNumbers
    +   });
    + } catch (err) {
    +   console.log( 'The following error occurred while creating contact: ' + err.name);
    + }
    + 
    + try {
    +   if (contact) {
    +     addressbook.add(contact);
    +     console.log('Contact was added with ID ' + contact.id);
    +   }
    + } catch (err) {
    +   console.log( 'The following error occurred while adding: ' + err.name);
    + }
    + 
    +

    Constructors

    @@ -4402,7 +4438,22 @@ This interface is used by other APIs to uniquely and globally identify contacts.

    Constructors

    -
    ContactRef(AddressBookId addressBookId, ContactId contactId);
    +
    +
    ContactRef(AddressBookId addressBookId, ContactId contactId);
    +
    +

    Code example:

       // Gets the default address book.
    +   var addressbook = tizen.contact.getDefaultAddressBook();
    +
    +   // Creates a new contact:
    +   var eve = new tizen.Contact();
    +   eve.name = new tizen.ContactName({firstName:'Eve', lastName:'Green'});
    +   addressbook.add(eve);
    +
    +   // Creates a reference to this contact:
    +   var refToEve = new tizen.ContactRef(addressbook.id, eve.id);
    + 
    +
    +

    Attributes

    @@ -4487,7 +4538,14 @@ See the ContactName interface for more information about the members.

    Constructors

    -
    ContactName(optional ContactNameInit? nameInitDict);
    +
    +
    ContactName(optional ContactNameInit? nameInitDict);
    +
    +

    Code example:

       var myContactName = new tizen.ContactName(
    +      {prefix : "Mr.", firstName : "John", lastName : "Doe"});
    + 
    +
    +

    Attributes

    @@ -5837,15 +5895,15 @@ See code example below.

    Code example:

     var name = new tizen.ContactName({ firstName: 'Anna' });
     
    -  var contact_extension1 = new tizen.ContactExtension({ data1: 20, data2: 'Place of birth: Elbląg' });
    -  var contact_extension2 = new tizen.ContactExtension({ data3: 'Favourite color: green' });
    -  var contact1 = new tizen.Contact({
    -    name: name,
    -    extensions: [ contact_extension1, contact_extension2 ]
    -  });
    + var contact_extension1 = new tizen.ContactExtension({ data1: 20, data2: 'Place of birth: Elbląg' });
    + var contact_extension2 = new tizen.ContactExtension({ data3: 'Favourite color: green' });
    + var contact1 = new tizen.Contact({
    +   name: name,
    +   extensions: [ contact_extension1, contact_extension2 ]
    + });
     
    -  console.log(contact1.extensions[1].data3); // It shows: 'Favourite color: green'
    -
    + console.log(contact1.extensions[1].data3); // It shows: 'Favourite color: green' +

    Constructors

    @@ -6010,6 +6068,27 @@ get or save a list of persons.
  • +
    +

    Code example:

       function onerror(err) {
    +     console.log("The following error occurred " + err.name);
    +   }
    +
    +   function onsuccess(persons) {
    +     var p;
    +
    +     // log each found person's name to the console:
    +     for (p = 0; p < persons.length; p += 1) {
    +       console.log("Name: " + persons[p].displayName);
    +     }
    +   }
    +
    +   try {
    +     tizen.contact.find(onsuccess, onerror);
    +   } catch (err) {
    +     console.log("The following error occurred while finding: " + err.name);
    +   }
    + 
    +
    @@ -6108,6 +6187,20 @@ get address books. +
    +

    Code example:

       function errorCB(err) {
    +     console.log("An error occurred: " + err.name);
    +   }
    +
    +   // A callback invoked on successful retrieval of all the Address Books.
    +   function addressBooksCB(addressBooks) {
    +     console.log(addressBooks.length + " address books available.");
    +   }
    +
    +   // Gets a list of available address books.
    +   tizen.contact.getAddressBooks(addressBooksCB, errorCB);
    + 
    +
    @@ -6160,6 +6253,38 @@ book change occurs (contact addition/update/deletion). +
    +

    Code example:

       var watcherId = 0; // watcher identifier
    +   var addressbook = tizen.contact.getDefaultAddressBook();
    +
    +   var watcher = {
    +     oncontactsadded: function(contacts) {
    +       console.log(contacts.length + " contacts were added");
    +     },
    +     oncontactsupdated: function(contacts) {
    +       console.log(contacts.length + " contacts were updated");
    +     },
    +     oncontactsremoved: function(ids) {
    +       console.log(ids.length + " contacts were removed");
    +     }
    +   };
    +
    +   // Registers to be notified when the address book changes.
    +   watcherId = addressbook.addChangeListener(watcher);
    +
    +   // Adds a new contact to invoke an oncontactsadded call:
    +   try {
    +     var contact = new tizen.Contact({name : new tizen.ContactName({
    +                                         firstName : 'John', lastName : 'Doe', 
    +                                         nicknames : ['Johnny']}),
    +                                      emails : [new tizen.ContactEmailAddress('john@doe.com')],
    +                                      phoneNumbers : [new tizen.ContactPhoneNumber('789456123')]});
    +     addressbook.add(contact);
    +   } catch (err) {
    +     console.log('An error occurred while adding a contact: ' + err.name + ", " + err.message);
    +   }
    + 
    +
    oncontactsupdated @@ -6183,6 +6308,48 @@ book change occurs (contact addition/update/deletion). +
    +

    Code example:

       var watcherId = 0; // watcher identifier
    +   var addressbook = tizen.contact.getDefaultAddressBook();
    +
    +   var watcher = {
    +     oncontactsadded: function(contacts) {
    +       console.log(contacts.length + " contacts were added");
    +     },
    +     oncontactsupdated: function(contacts) {
    +       console.log(contacts.length + " contacts were updated");
    +     },
    +     oncontactsremoved: function(ids) {
    +       console.log(ids.length + " contacts were removed");
    +     }
    +   };
    +
    +   // Registers to be notified when the address book changes.
    +   watcherId = addressbook.addChangeListener(watcher);
    +
    +   // Updates a contact to invoke an oncontactsupdated call:
    +   function errorCB(error) {
    +     console.log(error.name + ": " + error.message);
    +   }
    +
    +   function contactsFoundCB(contacts) {
    +     contacts[0].name.firstName = 'Stanley';
    +     try {
    +       addressbook.update(contacts[0]);
    +       console.log('Successfully updated.');
    +     } catch (error) {
    +       console.log(error.name + ": " + error.message);
    +     }
    +   }
    +
    +   var filter = new tizen.AttributeFilter('name.lastName', 'EXACTLY', 'Doe');
    +   try {
    +     addressbook.find(contactsFoundCB, errorCB, filter);
    +   } catch (error) {
    +     console.log(error.name + ": " + error.message);
    +   }
    + 
    +
    oncontactsremoved @@ -6206,6 +6373,52 @@ book change occurs (contact addition/update/deletion). +
    +

    Code example:

       var watcherId = 0; // watcher identifier
    +   var addressbook = tizen.contact.getDefaultAddressBook();
    +
    +   var watcher = {
    +     oncontactsadded: function(contacts) {
    +       console.log(contacts.length + " contacts were added");
    +     },
    +     oncontactsupdated: function(contacts) {
    +       console.log(contacts.length + " contacts were updated");
    +     },
    +     oncontactsremoved: function(ids) {
    +       console.log(ids.length + " contacts were removed");
    +     }
    +   };
    +
    +   // Registers to be notified when the address book changes.
    +   watcherId = addressbook.addChangeListener(watcher);
    +
    +   // Removes a first contact whose name is 'Doe'
    +   // to invoke oncontactsremoved call:
    +   function onErrorCB(err) {
    +     console.log('An error occurred: ' + err.name);
    +   }
    +
    +   function onContactsFoundCB(contacts) {
    +     if(contacts.length > 0) {
    +       try {
    +         addressbook.remove(contacts[0].id);
    +         console.log('First contact has been removed.');
    +       } catch (err) {
    +         console.log('An error occurred while removing: ' + err.name);
    +       }
    +     } else {
    +       console.log('No contacts to delete.');
    +     }
    +   }
    +
    +   var filter = new tizen.AttributeFilter('name.lastName', 'EXACTLY', 'Doe');
    +   try {
    +     addressbook.find(onContactsFoundCB, onErrorCB, filter);
    +   } catch (err) {
    +     console.log('An error occured while finding: ' + err.name);
    +   }
    + 
    +
    @@ -6257,6 +6470,25 @@ list change occurs (person addition/update/deletion). +
    +

    Code example:

       var watcherId = 0; // watcher identifier
    +
    +   var watcher = {
    +     onpersonsadded: function(persons) {
    +       console.log(persons.length + " persons were added");
    +     },
    +     onpersonsupdated: function(persons) {
    +       console.log(persons.length + " persons were updated");
    +     },
    +     onpersonsremoved: function(ids) {
    +       console.log(ids.length + " persons were deleted");
    +     }
    +   };
    +
    +   // Registers to be notified when the address book changes.
    +   watcherId = tizen.contact.addChangeListener(watcher);
    + 
    +
    onpersonsupdated @@ -6280,6 +6512,25 @@ list change occurs (person addition/update/deletion). +
    +

    Code example:

       var watcherId = 0; // watcher identifier
    +
    +   var watcher = {
    +     onpersonsadded: function(persons) {
    +       console.log(persons.length + " persons were added");
    +     },
    +     onpersonsupdated: function(persons) {
    +       console.log(persons.length + " persons were updated");
    +     },
    +     onpersonsremoved: function(ids) {
    +       console.log(ids.length + " persons were deleted");
    +     }
    +   };
    +
    +   // Registers to be notified when the address book changes.
    +   watcherId = tizen.contact.addChangeListener(watcher);
    + 
    +
    onpersonsremoved @@ -6303,6 +6554,25 @@ list change occurs (person addition/update/deletion). +
    +

    Code example:

       var watcherId = 0; // watcher identifier
    +
    +   var watcher = {
    +     onpersonsadded: function(persons) {
    +       console.log(persons.length + " persons were added");
    +     },
    +     onpersonsupdated: function(persons) {
    +       console.log(persons.length + " persons were updated");
    +     },
    +     onpersonsremoved: function(ids) {
    +       console.log(ids.length + " persons were deleted");
    +     }
    +   };
    +
    +   // Registers to be notified when the address book changes.
    +   watcherId = tizen.contact.addChangeListener(watcher);
    + 
    +
    @@ -6716,27 +6986,27 @@ list change occurs (person addition/update/deletion). interface ContactExtension { attribute long data1; - + attribute DOMString? data2; - + attribute DOMString? data3; - + attribute DOMString? data4; - + attribute DOMString? data5; - + attribute DOMString? data6; - + attribute DOMString? data7; - + attribute DOMString? data8; - + attribute DOMString? data9; - + attribute DOMString? data10; - + attribute DOMString? data11; - + attribute DOMString? data12; }; diff --git a/org.tizen.web.apireference/html/device_api/mobile/tizen/time.html b/org.tizen.web.apireference/html/device_api/mobile/tizen/time.html index 3750c3b..0001eb1 100644 --- a/org.tizen.web.apireference/html/device_api/mobile/tizen/time.html +++ b/org.tizen.web.apireference/html/device_api/mobile/tizen/time.html @@ -306,6 +306,14 @@ Get timezones using getLocalTimezone() and getAvailableTimezones(). <

    Code example:

     console.log("The local time zone is " + tizen.time.getLocalTimezone());
      
    +
    +

    Code example:

     // Note that it is possible to get the time zone description in other formats, e.g. by calling:
    + now = new tizen.TZDate(new Date(), 'Asia/Manila');
    +
    + // Outputs "Wednesday, January 27, 2016, 8:46:00 PM GMT+0800 Philippines Time"
    + console.log(now.toString());
    + 
    +
    getAvailableTimezones @@ -343,6 +351,18 @@ with the most general descriptor first and the most specific one last. For examp console.log("The device supports " + tzids.length + " time zones."); +
    +

    Code example:

     var tzids = tizen.time.getAvailableTimezones();
    + var currentLocation = 'Europe/Berlin';
    +
    + // checks whether an entry 'Europe/Berlin' exists in the array.
    + if (tzids.indexOf(currentLocation) > -1) {
    +   console.log('The device supports ' + currentLocation + ' timezone.');
    + } else {
    +   console.log('The device does not support ' + currentLocation + ' timezone.');
    + }
    + 
    +
    getDateFormat @@ -398,6 +418,16 @@ date format (23/10/2011) instead of a long date format ("Monday, October 23 2011

    +
    +

    Code example:

     // Gets the long date format, e.g. "D, M d y".
    + var dateFormat = tizen.time.getDateFormat();
    +
    + // Gets the short date format, e.g. "d/m/y".
    + var shortDateFormat = tizen.time.getDateFormat(true); 
    +
    + console.log("Long date format: " + dateFormat);
    + 
    +
    getTimeFormat @@ -441,6 +471,13 @@ Examples of string formats include: "h:m:s ap", "h:m:s".

    +
    +

    Code example:

     // Gets the time format, e.g. "h:m:s ap".
    + var timeFormat = tizen.time.getTimeFormat();
    +
    + console.log(timeFormat);
    + 
    +
    isLeapYear @@ -686,6 +723,7 @@ date/time in a predefined timezone. If its date/time exceeds the platform limit, TZDate will be invalid.
      [Constructor(optional Date? datetime, optional DOMString? timezone),
    +  
        Constructor(long year, long month, long day, optional long? hours, optional long? minutes, optional long? seconds, optional long? milliseconds, optional DOMString? timezone)]
     
       interface TZDate {
    @@ -804,6 +842,17 @@ If its date/time exceeds the platform limit, TZDate will be invalid.
     year : The year of TZDate. If it is between 0 and 99, 1900 will be added to it like Javascript Date object.                
                   
                  
    +
    +

    Code example:

     // Creates a new TZDate object with current date/time and timezone:
    + var now = new tizen.TZDate();
    + 
    + // Creates a new TZDate object with date set to 1st of January 2016 in time zone for Germany:
    + var newYear = new tizen.TZDate(new Date("2016-01-01"), 'Europe/Berlin');
    +
    + // Creates a new TZDate object with values set explicitly:
    + var myDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, 'Europe/Berlin');
    + 
    +
    @@ -826,6 +875,11 @@ If its date/time exceeds the platform limit, TZDate will be invalid.

    Return value:

    long The day of the month.
    +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + console.log(someDate.getDate()); // should output 31.
    + 
    +
    setDate @@ -855,13 +909,19 @@ For example, if TZDate's month is May and parameter is 32, it will be set to Jun +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + someDate.setDate(1); // Changes the day of month to 1.
    + console.log(someDate.getDate()); // should output 1.
    + 
    +
    getDay
    - Gets the day of the week (from 0-6). + Gets the day of the week (from 0-6). 0 denotes Sunday, 1 denotes Monday and so on.
    long getDay();
                  
    @@ -873,6 +933,12 @@ For example, if TZDate's month is May and parameter is 32, it will be set to Jun

    Return value:

    long The day of the week +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + console.log(someDate.getDay()); // should output "5", because 31st of December 1999 was friday.
    +     
    +
    +
    getFullYear @@ -897,6 +963,11 @@ For example, 1 = AD 1, 0 = BC 1, -1 = BC 2.

    Return value:

    long The year +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + console.log(someDate.getFullYear()); // should output 1999.
    + 
    +
    setFullYear @@ -920,6 +991,12 @@ For example, 1 = AD 1, 0 = BC 1, -1 = BC 2. +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + someDate.setFullYear(2099); // Changes the year to 2099.
    + console.log(someDate.getFullYear()); // should output 2099.
    + 
    +
    getHours @@ -938,6 +1015,11 @@ For example, 1 = AD 1, 0 = BC 1, -1 = BC 2.

    Return value:

    long The hour +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + console.log(someDate.getHours()); // should output 23.
    + 
    +
    setHours @@ -967,6 +1049,12 @@ For example, calling setHours(24) results in setting hour to 00:00 and date to t +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + someDate.setHours(15); // Sets the hour to 3 PM.
    + console.log(someDate.getHours()); // should output 15.
    + 
    +
    getMilliseconds @@ -985,6 +1073,11 @@ For example, calling setHours(24) results in setting hour to 00:00 and date to t

    Return value:

    long The milliseconds +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + console.log(someDate.getMilliseconds()); // should output 999.
    + 
    +
    setMilliseconds @@ -1014,6 +1107,12 @@ For example, calling setMilliseconds(1000) results in setting milliseconds to 0 +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + someDate.setMilliseconds(42);
    + console.log(someDate.getMilliseconds()); // should output 42.
    + 
    +
    getMinutes @@ -1032,6 +1131,11 @@ For example, calling setMilliseconds(1000) results in setting milliseconds to 0

    Return value:

    long The minutes +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + console.log(someDate.getMinutes()); // should output 59.
    + 
    +
    setMinutes @@ -1062,13 +1166,19 @@ For example, calling setMinutes(60) results in setting minutes to 0 and adding o +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + someDate.setMinutes(58);
    + console.log(someDate.getMinutes()); // should output 58.
    + 
    +
    getMonth
    - Gets the month (from 0-11). + Gets the month (from 0-11).
    Note: January is denoted as 0, February as 1, and so on till December, which is denoted as 11.
    long getMonth();
                  
    @@ -1080,6 +1190,11 @@ For example, calling setMinutes(60) results in setting minutes to 0 and adding o

    Return value:

    long The month +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + console.log(someDate.getMonth()); // should output 11.
    + 
    +
    setMonth @@ -1109,6 +1224,12 @@ For example, calling setMonth(12) results in setting month to 0 and adding one y +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + someDate.setMonth(2); // Changes the month to March.
    + console.log(someDate.getMonth()); // should output 2.
    + 
    +
    getSeconds @@ -1127,6 +1248,11 @@ For example, calling setMonth(12) results in setting month to 0 and adding one y

    Return value:

    long The seconds +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + console.log(someDate.getSeconds()); // should output 59.
    + 
    +
    setSeconds @@ -1156,6 +1282,12 @@ For example, calling setSeconds(60) results in setting seconds to 0 and adding o +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + someDate.setSeconds(23);
    + console.log(someDate.getSeconds()); // should output 23.
    + 
    +
    getUTCDate @@ -1174,6 +1306,11 @@ For example, calling setSeconds(60) results in setting seconds to 0 and adding o

    Return value:

    long The day of the month, according to universal time +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + console.log(someDate.getUTCDate()); // should output 31.
    + 
    +
    setUTCDate @@ -1203,6 +1340,12 @@ For example, calling setUTCDate(32) when TZDate's month is May results in settin +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + someDate.setUTCDate(5) // Change the day of month to 5th.
    + console.log(someDate.getUTCDate()); // should output 5.
    + 
    +
    getUTCDay @@ -1221,6 +1364,11 @@ For example, calling setUTCDate(32) when TZDate's month is May results in settin

    Return value:

    long The day of the week, according to universal time +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + console.log(someDate.getUTCDay()); // should output 5, since 31st of December 1999 was friday.
    + 
    +
    getUTCFullYear @@ -1245,6 +1393,11 @@ For example, 1 = AD 1, 0 = BC 1, -1 = BC 2.

    Return value:

    long The year, according to universal time +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + console.log(someDate.getUTCFullYear()); // should output 1999.
    + 
    +
    setUTCFullYear @@ -1268,6 +1421,12 @@ For example, 1 = AD 1, 0 = BC 1, -1 = BC 2. +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + someDate.setUTCFullYear(2099); // Change the year to 2099, universal time.
    + console.log(someDate.getUTCFullYear()); // should output 2099.
    + 
    +
    getUTCHours @@ -1286,6 +1445,11 @@ For example, 1 = AD 1, 0 = BC 1, -1 = BC 2.

    Return value:

    long The hour, according to universal time +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + console.log(someDate.getUTCHours()); // should output 23.
    + 
    +
    setUTCHours @@ -1315,6 +1479,12 @@ For example, calling setUTCHours(24) results in setting hour to 0 and adding one +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + someDate.setUTCHours(15);
    + console.log(someDate.getUTCHours()); // should output 15.
    + 
    +
    getUTCMilliseconds @@ -1333,6 +1503,11 @@ For example, calling setUTCHours(24) results in setting hour to 0 and adding one

    Return value:

    long The milliseconds, according to universal time +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + console.log(someDate.getUTCMilliseconds()); // should output 999.
    + 
    +
    setUTCMilliseconds @@ -1362,6 +1537,12 @@ For example, calling setUTCMilliseconds(1000) results in setting milliseconds to +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + someDate.setUTCMillisecond(42);
    + console.log(someDate.getUTCMilliseconds()); // should output 42.
    + 
    +
    getUTCMinutes @@ -1380,6 +1561,11 @@ For example, calling setUTCMilliseconds(1000) results in setting milliseconds to

    Return value:

    long The minutes, according to universal time +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + console.log(someDate.getUTCMinutes()); // should output 59.
    + 
    +
    setUTCMinutes @@ -1409,13 +1595,19 @@ For example, calling setUTCMinutes(60) results in setting minutes to 0 and addin +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + someDate.setUTCMinutes(58);
    + console.log(someDate.getUTCMinutes()); // should output 58.
    + 
    +
    getUTCMonth
    - Gets the month, according to universal time (from 0-11). + Gets the month, according to universal time (from 0-11).
    Note: January is denoted as 0, February as 1 and so on till December, which is denoted as 11.
    long getUTCMonth();
                  
    @@ -1427,6 +1619,11 @@ For example, calling setUTCMinutes(60) results in setting minutes to 0 and addin

    Return value:

    long The month, according to universal time +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + console.log(someDate.getUTCMonth()); // should output 11.
    + 
    +
    setUTCMonth @@ -1456,6 +1653,12 @@ For example, calling setUTCMonth(12) results in setting month to 0 and adding on +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + someDate.setUTCMonth(2); // Sets the month to March, according to the universal time.
    + console.log(someDate.getUTCMonth()); // should output 2.
    + 
    +
    getUTCSeconds @@ -1474,6 +1677,11 @@ For example, calling setUTCMonth(12) results in setting month to 0 and adding on

    Return value:

    long The seconds, according to universal time +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + console.log(someDate.getUTCSeconds()); // should output 59.
    + 
    +
    setUTCSeconds @@ -1503,6 +1711,12 @@ For example, calling setUTCSeconds(60) results in setting seconds to 0 and addin +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + someDate.setUTCSeconds(23);
    + console.log(someDate.getUTCSeconds()); // should output 23.
    + 
    +
    getTimezone @@ -1531,6 +1745,11 @@ This attribute uniquely identifies the timezone.

    Return value:

    DOMString The string timezone identifier
    If TZDate is invalid, it will return 'Invalid Date'. +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + console.log(someDate.getTimezone()); // should output "Europe/London".
    + 
    +
    toTimezone @@ -1575,6 +1794,14 @@ is not recognized as a valid timezone identifier. +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + var koreanDate = someDate.toTimezone("Asia/Seoul");
    +
    + // Should output: "Saturday, January 1, 2000, 8:59:59 AM GMT+0900 South Korea Time" 
    + console.log(someDate.toString());
    + 
    +
    toLocalTimezone @@ -1600,6 +1827,16 @@ is not recognized as a valid timezone identifier.

    +
    +

    Code example:

     // This example assumes that the device's local time zone is set to Asia/Seoul.
    + // You may get different results depending on your local time zone settings.
    + var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Europe/London");
    + var localDate = someDate.toLocalTimezone();
    +
    + // Should output: "Saturday, January 1, 2000, 8:59:59 AM GMT+0900 South Korea Time" 
    + console.log(localDate.toString());
    + 
    +
    toUTC @@ -1625,6 +1862,14 @@ is not recognized as a valid timezone identifier.

    +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, "Asia/Seoul");
    + var utcDate = someDate.toUTC();
    +
    + // Should output: "Friday, December 31, 1999, 2:59:59 PM GMT+0000 GMT" 
    + console.log(utcDate.toString());
    + 
    +
    difference @@ -1685,6 +1930,30 @@ is not compatible with the expected type for that parameter. +
    +

    Code example:

     // Prepares two TZDates pointing at new year eves in 2011 and 2012, respectively:
    + var newYearEve2011 = new tizen.TZDate(2011, 0, 0, 0, 0, 0, 0, "Europe/London");
    + var newYearEve2012 = new tizen.TZDate(2012, 0, 0, 0, 0, 0, 0, "Europe/London");
    +
    + // Calculates how much is the difference between  those two dates:
    + var difference = newYearEve2012.difference(newYearEve2011);
    +
    + // Should output: "The difference is 365 DAYS" (since none of those dates have time component)
    + console.log("The difference is " + difference.length + " " + difference.unit);
    + 
    +
    +
    +

    Code example:

     // Prepares two TZDates pointing at 6:00 PM and 8:00 PM on the same day:
    + var joggingStart = new tizen.TZDate(2015, 6, 6, 18, 0, 0, 0, "Europe/London");
    + var joggingEnd = new tizen.TZDate(2015, 6, 6, 20, 0, 0, 0, "Europe/London");
    +
    + // Calculates how much is the difference between  those two dates:
    + var difference = joggingEnd.difference(joggingStart);
    +
    + // Should output: "The difference is 7200000 MSECS" (since both of those dates do have time component)
    + console.log("The difference is " + difference.length + " " + difference.unit);
    + 
    +
    equalsTo @@ -1730,6 +1999,33 @@ is not compatible with the expected type for that parameter. +
    +

    Code example:

     var noonInEngland = new tizen.TZDate(2016, 0, 27, 12, 0, 0, 0, 'Europe/London');
    + var sameTimeInKorea = noonInEngland.toTimezone('Asia/Seoul');
    + var isTheSame = noonInEngland.equalsTo(sameTimeInKorea);
    +
    + // Those are the same dates (in different time zones), so the output should be "Those dates are equal."
    + if(isTheSame) {
    +   console.log("Those dates are equal.");
    + } else {
    +   console.log("Those dates are not equal.");
    + }
    + 
    +
    +
    +

    Code example:

     var noonInEngland = new tizen.TZDate(2016, 0, 27, 12, 0, 0, 0, 'Europe/London');
    + var noonInKorea = new tizen.TZDate(2016, 0, 27, 12, 0, 0, 0, 'Asia/Seoul');
    + var isTheSame = noonInEngland.equalsTo(noonInKorea);
    +
    + // Those are not the same dates (obviously, noon in London is not noon in Seoul),
    + // so the output should be "Those dates are not equal."
    + if(isTheSame) {
    +   console.log("Those dates are equal.");
    + } else {
    +   console.log("Those dates are not equal.");
    + }
    + 
    +
    earlierThan @@ -1775,6 +2071,20 @@ is not compatible with the expected type for that parameter. +
    +

    Code example:

     // Create a new TZDate object pointing to noon in London:
    + var tzd1 = new tizen.TZDate(2016, 0, 1, 12, 0, 0, 0, 'Europe/London');
    +
    + // Create a new TZDate object pointing to 6 PM in Seoul on the same day:
    + var tzd2 = new tizen.TZDate(2016, 0, 1, 18, 0, 0, 0, 'Asia/Seoul');
    +
    + // is 12:00 local time in London earlier than 18:00 local time in Seoul?
    + var isEarlier = tzd1.earlierThan(tzd2);
    + 
    + // should output 'false', since local time in Seoul is GMT (London) + 9 hours.
    + console.log(isEarlier);
    + 
    +
    laterThan @@ -1820,6 +2130,20 @@ is not compatible with the expected type for that parameter. +
    +

    Code example:

     // Create a new TZDate object pointing to noon in London:
    + var tzd1 = new tizen.TZDate(2016, 0, 1, 12, 0, 0, 0, 'Europe/London');
    +
    + // Create a new TZDate object pointing to 6 PM in Seoul on the same day:
    + var tzd2 = new tizen.TZDate(2016, 0, 1, 18, 0, 0, 0, 'Asia/Seoul');
    +
    + // is 12:00 local time in London earlier than 18:00 local time in Seoul?
    + var isLater = tzd1.laterThan(tzd2);
    + 
    + // should output 'true', since local time in Seoul is GMT (London) + 9 hours.
    + console.log(isLater);
    + 
    +
    addDuration @@ -1892,6 +2216,13 @@ is not compatible with the expected type for that parameter.

    Return value:

    DOMString The date portion of the TZDate object as a string, using locale conventions
    If TZDate is invalid, it will return 'Invalid Date'. +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, 'Europe/London');
    +
    + // Output example (depends on locale settings): "Friday, December 31, 1999"
    + console.log(someDate.toLocaleDateString());
    + 
    +
    toLocaleTimeString @@ -1910,6 +2241,13 @@ is not compatible with the expected type for that parameter.

    Return value:

    DOMString The time portion of the TZDate object as a string, using locale conventions
    If TZDate is invalid, it will return 'Invalid Date'. +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, 'Europe/London');
    +
    + // Output example (depends on locale settings): "11:59:59 PM"
    + console.log(someDate.toLocaleTimeString());
    + 
    +
    toLocaleString @@ -1928,6 +2266,13 @@ is not compatible with the expected type for that parameter.

    Return value:

    DOMString The string representation of the TZDate object, using locale conventions
    If TZDate is invalid, it will return 'Invalid Date'. +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, 'Europe/London');
    +
    + // Output example (depends on locale settings): "Friday, December 31, 1999, 11:59:59 PM"
    + console.log(someDate.toLocaleString());
    + 
    +
    toDateString @@ -1946,6 +2291,13 @@ is not compatible with the expected type for that parameter.

    Return value:

    DOMString The date portion of the TZDate object as a string
    If TZDate is invalid, it will return 'Invalid Date'. +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, 'Europe/London');
    +
    + // Should output: "Friday, December 31, 1999"
    + console.log(someDate.toDateString());
    + 
    +
    toTimeString @@ -1964,6 +2316,13 @@ is not compatible with the expected type for that parameter.

    Return value:

    DOMString The time portion of the TZDate object as a string
    If TZDate is invalid, it will return 'Invalid Date'. +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, 'Europe/London');
    +
    + // Should output: "11:59:59 PM GMT+0000 United Kingdom Time"
    + console.log(someDate.toTimeString());
    + 
    +
    toString @@ -1982,6 +2341,13 @@ is not compatible with the expected type for that parameter.

    Return value:

    DOMString The string representation of the TZDate object
    If TZDate is invalid, it will return 'Invalid Date'. +
    +

    Code example:

     var someDate = new tizen.TZDate(1999, 11, 31, 23, 59, 59, 999, 'Europe/London');
    +
    + // Should output: "Friday, December 31, 1999, 11:59:59 PM GMT+0000 United Kingdom Time"
    + console.log(someDate.toString());
    + 
    +
    getTimezoneAbbreviation @@ -1990,9 +2356,9 @@ is not compatible with the expected type for that parameter.
    Determines the time zone abbreviation to be used at a particular date in the time zone.
    -

    Deprecated. +

    Deprecated. Deprecated since 2.1. -

    +

    DOMString getTimezoneAbbreviation();
                  

    @@ -2085,6 +2451,14 @@ identified by the TZDate object.

    +
    +

    Code example:

     var summertime = new tizen.TZDate(2015, 6, 1, 10, 0, 0, 0, 'Europe/London');
    + var wintertime = new tizen.TZDate(2015, 0, 1, 10, 0, 0, 0, 'Europe/London');
    +
    + var isDstActiveInSummer = summertime.isDST(); // true
    + var isDstActiveInWinter = wintertime.isDST(); // false
    + 
    +
    getPreviousDSTTransition @@ -2110,6 +2484,17 @@ identified by the TZDate object.

    +
    +

    Code example:

     // Creates the TZDate object pointing to January 2016.
    + var winter16 = new tizen.TZDate(2016, 0, 1, 10, 0, 0, 0, 'Europe/London');
    +
    + // Gets the date of previous DST transition:
    + var previousDstTransition = winter16.getPreviousDSTTransition();
    + 
    + // Should output: "Sunday, October 25, 2015, 1:00:00 AM GMT+0000 United Kingdom Time"
    + console.log(previousDstTransition.toString());
    + 
    +
    getNextDSTTransition @@ -2135,6 +2520,17 @@ identified by the TZDate object.

    +
    +

    Code example:

     // Creates the TZDate object pointing to January 2016.
    + var winter16 = new tizen.TZDate(2016, 0, 1, 10, 0, 0, 0, 'Europe/London');
    +
    + // Gets the date of next DST transition:
    + var nextDstTransition = winter16.getNextDSTTransition();
    + 
    + // Should output: "Sunday, March 27, 2016, 2:00:00 AM GMT+0100 United Kingdom Time"
    + console.log(nextDstTransition.toString());
    + 
    +
    @@ -2145,12 +2541,14 @@ identified by the TZDate object. The TimeDuration interface that contains the length and its associated time unit.
      [Constructor(long long length, optional TimeDurationUnit? unit)]
    +  
       interface TimeDuration
       {
         attribute long long length;
     
         attribute TimeDurationUnit unit;
     
    +
         TimeDuration difference(TimeDuration other) raises(WebAPIException);
     
         boolean equalsTo(TimeDuration other) raises(WebAPIException);
    @@ -2163,14 +2561,19 @@ identified by the TZDate object.
                 Since: 
      1.0
               

    +
    +

    Constructors

    +
    +
    + The TimeDuration interface that contains the length and its associated time unit. +
    +
    TimeDuration(long long length, optional TimeDurationUnit? unit);

    Code example:

     var now = tizen.time.getCurrentDateTime();
      var tomorrow = now.addDuration(new tizen.TimeDuration(1, "DAYS")); // Becomes tomorrow, same time.
      
    -
    -

    Constructors

    -
    TimeDuration(long long length, optional TimeDurationUnit? unit);
    +

    Attributes

    @@ -2203,6 +2606,17 @@ The default value is "MSECS" (milliseconds unit). Since: 1.0

    +
    +

    Code example:

     
    + // Changing both length and unit of existing TimeDuration objects is possible:
    +
    + var now = tizen.time.getCurrentDateTime();
    + var threeHours = new tizen.TimeDuration();
    + threeHours.length = 3;
    + threeHours.unit = "HOURS";
    + var later = now.addDuration(threeHours); // later points to a time three hours from now.
    + 
    +
    @@ -2459,6 +2873,7 @@ is not compatible with the expected type for that parameter. }; [Constructor(optional Date? datetime, optional DOMString? timezone), + Constructor(long year, long month, long day, optional long? hours, optional long? minutes, optional long? seconds, optional long? milliseconds, optional DOMString? timezone)] interface TZDate { @@ -2564,12 +2979,14 @@ is not compatible with the expected type for that parameter. }; [Constructor(long long length, optional TimeDurationUnit? unit)] + interface TimeDuration { attribute long long length; attribute TimeDurationUnit unit; + TimeDuration difference(TimeDuration other) raises(WebAPIException); boolean equalsTo(TimeDuration other) raises(WebAPIException); diff --git a/org.tizen.web.apireference/html/device_api/mobile/tizen/tizen.html b/org.tizen.web.apireference/html/device_api/mobile/tizen/tizen.html index 41a5a0d..4de7cb5 100644 --- a/org.tizen.web.apireference/html/device_api/mobile/tizen/tizen.html +++ b/org.tizen.web.apireference/html/device_api/mobile/tizen/tizen.html @@ -522,6 +522,25 @@ The intersection - used to filter objects that match all the filters it includes tizen.content.find(findCB, errorCB, null, filter, null, count, offset);
    +
    +

    Code example:

     // The following example retrieves all songs from the album "Tormato" and all songs by artist "Rush".
    + var count = 100;
    + var offset = 0;
    + var artistFilter = new tizen.AttributeFilter("artists", "EXACTLY", "Rush");
    + var albumFilter = new tizen.AttributeFilter("album", "EXACTLY", "Tormato");
    + var filter = new tizen.CompositeFilter("UNION", [albumFilter, artistFilter]);
    +
    + function errorCB(err) {
    +     console.log( 'The following error occurred: ' +  err.name);
    + }
    +
    + function findCB(contents) {
    +     console.log('Songs found:' + contents.length);
    + }
    +
    + tizen.content.find(findCB, errorCB, null, filter, null, count, offset);
    + 
    +

    Constructors

    @@ -655,6 +674,28 @@ By default, this attribute is set to ASC. Latitude and longitude are of the WGS84 datum.

    +
    +

    Code example:

       // This example utilizes methods from Tizen's HAM module to get current latitude and longitude.
    +   var myPosition;
    +
    +   // reads current position from the GPS module.
    +   function onChangedCB(info) {
    +     var latitude, longitude;
    +     latitude = info.gpsInfo[0].latitude;
    +     longitude = info.gpsInfo[0].longitude;
    +
    +     // packs these values in one variable:
    +     myPosition = new SimpleCoordinates(latitude, longitude);
    +   }
    +
    +   // starts monitoring GPS info periodically.
    +   try {
    +     tizen.humanactivitymonitor.start("GPS", onChangedCB, {callbackInterval: 120000, sampleInterval: 60000});
    +   } catch (err) {
    +     console.log(err.name + ": " + err.message);
    +   }
    + 
    +

    Constructors

    SimpleCoordinates(double latitude, double longitude);
    @@ -1365,6 +1406,7 @@ it silently fails and there is no further action. [Callback=FunctionOnly, NoInterfaceObject] interface ErrorCallback { + void onerror (WebAPIError error); }; };
    -- 2.7.4