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

Method

Description

Supported in emulator

time/getSystemTime

Returns 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
subscribe
No
Boolean
Flag 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 not subscribe. Call the method only once. (Default)

Call returns

NameRequiredTypeDescription
returnValue
Yes
Boolean
Flag that indicates success/failure of the request.
  • true: Success
  • false: Failure
subscribed
No
Boolean
Flag that indicates whether the subscription is enabled or not.
  • true: Enabled
  • false: Not enabled.
utc
Yes
Number
The number of milliseconds since Epoch (midnight of January 1, 1970, UTC), also known as the Unix time.
Yes
Object
The object that contains information about the current system time.
offset
Yes
Number
The number of minutes from UTC. This can be negative for time zones west of UTC, and positive for time zones east of UTC.
timezone
Yes
String
The current system time zone. It has the same format as the `TZ` environment variable. For more information, refer to http://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html.
TZ
Yes
String
Contains the time zone abbreviation in the standard Unix format, for example, PDT (which stands for Pacific Daylight Time). The `timezone` property corresponds to the current time zone of the system.
timeZoneFile
Yes
String
Linux zone information file for the currently set zone. For more information, refer to http://linux.die.net/man/5/tzfile.
NITZValid
Yes
String
Deprecated. Formerly it was used to alert the UI whether the method managed to set the time correctly using NITZ. Currently, it does not indicate anything meaningful.

Subscription returns

NameRequiredTypeDescription
utc
Yes
Number
The number of milliseconds since Epoch (midnight of January 1, 1970, UTC), also known as the Unix time.
Yes
Object
The object that contains information about the current system time.
offset
Yes
Number
The number of minutes from UTC. This can be negative for time zones west of UTC, and positive for time zones east of UTC.
timezone
Yes
String
The current system time zone. It has the same format as the `TZ` environment variable. For more information, refer to http://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html.
TZ
Yes
String
Contains the time zone abbreviation in the standard Unix format, for example, PDT (which stands for Pacific Daylight Time). The `timezone` property corresponds to the current time zone of the system.
timeZoneFile
Yes
String
Linux zone information file for the currently set zone. For more information, refer to http://linux.die.net/man/5/tzfile.
NITZValid
Yes
String
Deprecated. Formerly it was used to alert the UI whether the method managed to set the time correctly using NITZ. Currently, it does not indicate anything meaningful.
NITZValidTime
No
String
Indicates 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.
NITZValidZone
No
String
Indicates 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
} 

Name

Required

Type

Description

year

Yes

Number

The year

month

Yes

Number

The month (1 - 12)

dayOfWeek

No

Number

The day of the week (0 - 6)

day

Yes

Number

The day (1 - 31)

hour

Yes

Number

The hour (0 - 23)

minute

Yes

Number

The minute (0 - 59)

second

Yes

Number

The second (0 - 59 or 60 for leap seconds)

No Headings