NgxGoogleTimeZone
Angular service for Google's Time Zone API.
![w3soto](https://circleci.com/gh/w3soto/ngx-google-time-zone.svg?style=svg)
StackBlitz Demo
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
getTimeZone(tzReq: TimeZoneRequest): Observable<TimeZoneResponse>
Interfaces
export interface TimeZoneRequest {
lat: number,
lng: number,
timestamp?: number,
language?: string,
apiKey?: string
}
export interface TimeZoneResponse {
dstOffset: number,
rawOffset: number,
status: TimeZoneStatus,
timeZoneId: string,
timeZoneName: string,
}
export type TimeZoneStatus = 'OK' | 'ZERO_RESULTS' | 'OVER_DAILY_LIMIT' | 'OVER_QUERY_LIMIT' | 'REQUEST_DENIED' |
'INVALID_REQUEST' | 'UNKNOWN_ERROR';