ngx-google-time-zone
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

NgxGoogleTimeZone

Angular service for Google's Time Zone API.

w3soto

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

  • 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';

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.3
    33
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.3
    33
  • 1.0.2
    0
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i ngx-google-time-zone

Weekly Downloads

33

Version

1.0.3

License

MIT

Unpacked Size

36.6 kB

Total Files

16

Last publish

Collaborators

  • w3soto