Skip to content
Snippets Groups Projects
Select Git revision
  • 3b4c6eeb6c9fb9d683b3f7d0de817d5ee0de6cb4
  • master default protected
  • feature/iqrf_db_v2.7
  • v2.99.x
  • weblate
  • weblate-update
  • release/v2.6.x
  • feature/v3-network
  • release/v2.5.x
  • feature/issue#387
  • refacoring/tsconfig
  • roman/wip
  • feature/vue3_vuetify3
  • v3-fixes
  • v2.4.x
  • feature/monit-rework
  • feature/php8.x
  • fix/nginx-caching
  • standard/reset_db_coordinator
  • feature/php8.1+
  • feature/request_abort
  • v2.99.1
  • v2.6.6
  • v2.6.5
  • v2.99.0
  • v2.99.0-rc1
  • v2.6.3
  • v2.6.2
  • v2.6.1
  • v2.6.0
  • v2.6.0-rc1
  • v2.5.22
  • v2.6.0-beta1
  • v2.5.21
  • v2.5.20
  • v2.5.19
  • v2.5.18
  • v2.5.17
  • v2.5.16
  • v2.4.18
  • v2.5.15
41 results

TimeService.ts

Blame
  • TimeService.ts 1.61 KiB
    /**
     * Copyright 2023-2025 MICRORISC s.r.o.
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     *     http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */
    
    import { type AxiosResponse } from 'axios';
    
    import {
    	type TimeConfig,
    	type TimeSet,
    	type Timezone,
    } from '../../types/Gateway';
    import { BaseService } from '../BaseService';
    
    /**
     * Time service
     */
    export class TimeService extends BaseService {
    
    	/**
    	 * Retrieves current gateway time
    	 * @return {Promise<TimeConfig>} Current gateway time
    	 */
    	public async getTime(): Promise<TimeConfig> {
    		const response: AxiosResponse<TimeConfig> =
    			await this.axiosInstance.get('/gateway/time');
    		return response.data;
    	}
    
    	/**
    	 * Retrieves available time zones
    	 * @return {Promise<Timezone[]>} Available time zones
    	 */
    	public async listTimezones(): Promise<Timezone[]> {
    		const response: AxiosResponse<Timezone[]> =
    			await this.axiosInstance.get('/gateway/time/timezones');
    		return response.data;
    	}
    
    	/**
    	 * Updates gateway time and NTP configuration
    	 * @param {TimeSet} data Time and NTP configuration
    	 */
    	public async updateTime(data: TimeSet): Promise<void> {
    		await this.axiosInstance.post('/gateway/time', data);
    	}
    }