ngx-google-time-zone
v1.0.3
Published
Angular service for Google's Time Zone API.
Downloads
426
Readme
NgxGoogleTimeZone
Angular service for Google's Time Zone API.
Official Google Time Zone API documentation
Installation
npm -i ngx-google-time-zone
Example
For more details see projects/demo application
import { NgxGoogleTimeZoneModule } from "ngx-google-time-zone";
...
@NgModule({
imports: [
...,
NgxGoogleTimeZoneModule.forRoot({
apiKey: '---GOOGLE-API-KEY---'
}),
],
...
})
class AppModule { ... }
Usage
import { NgxGoogleTimeZoneService } from "ngx-google-time-zone";
@Component({
...
})
class AppComponent {
constructor(
private _gtz: NgxGoogleTimeZoneService
) {}
getTimeZone() {
this._gtz.getTimeZone({
lat: 48.743551,
lng: 18.914176
}).subscribe(resp => console.log('TimeZoneResponse:', resp));
}
}
Services
- NgxGoogleTimeZoneService
getTimeZone(tzReq: TimeZoneRequest): Observable<TimeZoneResponse>
Interfaces
- TimeZoneRequest
export interface TimeZoneRequest {
lat: number,
lng: number,
timestamp?: number, // in seconds
language?: string,
apiKey?: string // if not provided with NgxGoogleTimeZoneModule.forRoot(...)
}
- TimeZoneResponse
export interface TimeZoneResponse {
dstOffset: number,
rawOffset: number,
status: TimeZoneStatus,
timeZoneId: string,
timeZoneName: string,
}
- TimeZoneStatus
export type TimeZoneStatus = 'OK' | 'ZERO_RESULTS' | 'OVER_DAILY_LIMIT' | 'OVER_QUERY_LIMIT' | 'REQUEST_DENIED' |
'INVALID_REQUEST' | 'UNKNOWN_ERROR';