System Service

Service URI - luna://com.palm.systemservice

Provides information about the system time. Apps can subscribe to this method to get system time updates.

Methods

MethodDescriptionSupported in Emulator
time/getSystemTimeReturns the detailed information of a device.Yes

time/getSystemTime

Description

Requests the system time. Apps can subscribe to this method and receive notifications when the time zone changes and/or the system time changes by a significant amount (currently 5 minutes).

Parameters

NameRequiredTypeDescription
subscribeOptionalBooleanFlag that decides whether to subscribe or not.
If the app wants to receive notifications when the time zone changes and/or the system time changes by a system-defined threshold, it should set subscribe to true. The current system-defined threshold is 5 minutes.
If the app does not wish to receive notifications of change in time zone and/or the system time changes, it should set subscribe to false.
  • true: Subscribe.
  • false: Do no subscribe. Call the method only once. (Default)

Call returns

NameRequiredTypeDescription
returnValueRequiredBooleanFlag that indicates success/failure of the request.
  • true: Success
  • false: Failure
subscribedOptionalBooleanFlag that indicates whether the subscription is enabled or not.
  • true: Enabled
  • false: Not enabled.
utcRequiredNumberThe number of milliseconds since Epoch (midnight of January 1, 1970, UTC), also known as the Unix time.
localtimeRequiredObjectThe object that contains information about the current system time.
offsetRequiredNumberThe number of minutes from UTC. This can be negative for time zones west of UTC, and positive for time zones east of UTC.
timezoneRequiredStringThe current system time zone. It has the same format as the TZ environment variable. For information, visit http://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html.
TZRequiredStringContains the time zone abbreviation in the standard Unix format, for example, PDT (which stands for Pacific Daylight Time). The timezone corresponds to the current time zone of the system.
timeZoneFileRequiredStringLinux zone information file for the currently set zone. For more information, visit http://linux.die.net/man/5/tzfile.
NITZValidRequiredStringDeprecated. Formerly it was used to alert the UI whether if the method managed to set the time correctly using NITZ. Currently, it does not indicate anything meaningful.

Subscription return

NameRequiredTypeDescription
utcRequiredNumberThe number of milliseconds since Epoch (midnight of January 1, 1970, UTC), also know as the Unix time.
localtimeRequiredObjectThe object that contains information about the current system time.
offsetRequiredNumberThe number of minutes from UTC. This can be negative for time zones west of UTC, and positive for time zones east of UTC.
timezoneRequiredStringThe current system time zone. It has the same format as the TZ environment variable. For information, visit http://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html.
TZRequiredStringContains the time zone abbreviation in the standard Unix format, for example, PDT (which stands for Pacific Daylight Time). The timezone corresponds to the current time zone of the system.
timeZoneFileRequiredStringLinux zone information file for the currently set zone. For more information, visit http://linux.die.net/man/5/tzfile.
NITZValidRequiredStringDeprecated. Formerly it was used to alert the UI whether if the method managed to set the time correctly using NITZ. Currently, it does not indicate anything meaningful.
NITZValidTimeOptionalStringIndicates that a valid time was correctly set using NITZ. This value is needed because sometimes the time-zone may be received ahead of the time.
NITZValidZoneOptionalStringIndicates that a valid time-zone was correctly set using NITZ. This value is needed because sometimes the time may be received ahead of the time-zone.

Example

// One-time call
	var request = webOS.service.request('luna://com.palm.systemservice', {
	  method: 'time/getSystemTime',
	  parameters: { subscribe: false },
	  onSuccess: function (inResponse) {
		console.log('Result: ' + JSON.stringify(inResponse));
		// To-Do something
	  },
	  onFailure: function (inError) {
		console.log('Failed to get system time information');
		console.log('[' + inError.errorCode + ']: ' + inError.errorText);
		// To-Do something
		return;
	  },
	});
	
	// Subscription
	var subscriptionHandle;
	
	subscriptionHandle = webOS.service.request('luna://com.palm.systemservice', {
	  method: 'time/getSystemTime',
	  parameters: { subscribe: true },
	  onSuccess: function (inResponse) {
		if (!inResponse.subscribed) {
		  console.log('Failed to subscribe the system time information');
		  return;
		}
	
		console.log('Result: ' + JSON.stringify(inResponse));
		// To-Do something
	  },
	  onFailure: function (inError) {
		console.log('Failed to get system time information');
		console.log('[' + inError.errorCode + ']: ' + inError.errorText);
		// To-Do something
		return;
	  },
	});
	...
	// If you need to unsubscribe the data, use cancel() method as below
	subscriptionHandle.cancel();

Return example

{
  "timeZoneFile": "/var/luna/preferences/localtime",
  "utc": 1418745990,
  "localtime": {
    "month": 12,
    "day": 16,
    "hour": 11,
    "minute": 6,
    "year": 2014,
    "second": 30
  },
  "offset": -300,
  "timezone": "Asia/Seoul",
  "TZ": "EST",
  "systemTimeSource": "sdp"
}

See also

None

Object

LocalTime object

This object provides details of the current system time.

{
  "year": number,
  "month": number,
  "dayOfWeek": number,
  "day": number,
  "hour": number,
  "minute": number,
  "second": number
} 
NameRequiredTypeDescription
yearRequiredNumberThe year
monthRequiredNumberThe month (1-12)
dayOfWeekOptionalNumberDay of the week (0 - 6)
dayRequiredNumberThe day (1- 31)
hourRequiredNumberThe hour (0 - 23)
minuteRequiredNumberThe minute (0 - 59)
secondRequiredNumberThe second (0 - 59 or 60 for leap seconds)
No Headings