Merge pull request !223 from MangTsang/format
Timing and Time
Introduction
The timing and time module provides APIs for managing the system time.
Figure 1 Subsystem architecture

Directory Structure
/base/time/time_service
├── etc # Process configuration files
├── figures # Architecture diagram
├── interfaces # APIs for external systems and applications
│ └── innerkits # APIs between services
│ └── kits # APIs
├── profile # System service configuration files
└── services # Service implementation
Usage
Available JS APIs
Table 1 Major functions of systemTime
表 2 Major functions of systemTimer
表 3 parameter TimerOptions description of systemTimer
Sample Code
Example fo using systemTime
// Import the module.
import systemTime from '@ohos.systemTime';
// Set the system time asynchronously with a Promise.
var time = 1611081385000;
systemTime.setTime(time)
.then((value) => {
console.log(`success to systemTime.setTime: ${value}`);
}).catch((err) => {
console.error(`failed to systemTime.setTime because ${err.message}`)
});
// Set the system time asynchronously with a callback.
var time = 1611081385000;
systemTime.setTime(time, (err, value) => {
if (err) {
console.error(`failed to systemTime.setTime because ${err.message}`);
return;
}
console.log(`success to systemTime.setTime: ${value}`);
});
Example fo using systemTimer
// Import the module import systemTimer from '@ohos.systemTimer';
console.log("start")
var options:TimerOptions{
type:TIMER_TYPE_REALTIME,
repeat:false,
interval:Number.MAX_VALUE/2,
persistent:false
}
console.log("create timer")
let timerId = systemTimer.Timer(options)
console.log("start timer")
let startTimerRes = systemTimer.startTimer(timerId, 100000)
console.log("stop timer")
let stopTimerRes = systemTimer.stopTimer(timerId)
console.log("destroy timer")
let destroyTimerRes = systemTimer.destroyTimer(timerId)
console.log('end');
## Repositories Involved<a name="section1371113476307"></a>
**Misc services subsystem**
[time\_time\_service](https://gitee.com/openharmony/time_time_service/tree/master/)