-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a483629
commit 00609bd
Showing
13 changed files
with
1,747 additions
and
25 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { Routes } from "@angular/router"; | ||
import { CJsonYamlComponent } from "../converters/c-json-yaml/c-json-yaml.component"; | ||
import { FJsonComponent } from "../formatters/f-json/f-json.component"; | ||
import { FSqlComponent } from "../formatters/f-sql/f-sql.component"; | ||
import { TimeZonesComponent } from "../time/time-zones/time-zones.component"; | ||
|
||
|
||
export class RouteService{ | ||
|
||
|
||
public static getRoutes() | ||
{ | ||
const routes: Routes = []; | ||
for (const c of RouteService.routeCategories) | ||
{ | ||
for (const route of c.routes) | ||
{ | ||
routes.push({ path: route.url.substring(1), pathMatch: 'full', component: route.component }); | ||
} | ||
} | ||
return routes; | ||
} | ||
public static routeCategories = [ | ||
{ | ||
name: 'Formatters', | ||
routes: [ | ||
{ name: 'SQL', url: '/format/sql', component: FSqlComponent }, | ||
{ name: 'JSON', url: '/format/json', component: FJsonComponent } | ||
] | ||
}, | ||
{ | ||
name: 'Converters', | ||
routes: [ | ||
{ name: 'Json To Yaml', url: '/convert/json-yaml', component: CJsonYamlComponent }, | ||
] | ||
}, | ||
{ | ||
name: 'Time', | ||
routes: [ | ||
{ name: 'Time Zones', url: '/time/zones', component: TimeZonesComponent }, | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<h1>Time Zone Conversions</h1> | ||
<timepicker [(ngModel)]="selectedTime"></timepicker> | ||
<div class="flex-row"> | ||
<button class="btn btn-secondary" (click)="btnSwitch()">Switch</button> | ||
<div class="flex-column grow gap-24"> | ||
<div class="flex-column"> | ||
<label for="tzFrom">Time Zone From</label> | ||
|
||
<ng-select id="tzFrom" [items]="this.zones" bindLabel="text" [(ngModel)]="currentZone" | ||
(change)="timeZoneChanged()"></ng-select> | ||
</div> | ||
<div class="flex-column"> | ||
<label for="tzFrom">Time Zone To</label> | ||
<ng-select [items]="this.zones" bindLabel="text" [(ngModel)]="covertToZone" | ||
(change)="timeZoneChanged()"></ng-select> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
<div *ngIf="error()" class="error">{{error()}}</div> | ||
|
||
{{currentTime()}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
:host { | ||
display: flex; | ||
flex-direction: column; | ||
flex-grow: 1; | ||
gap: 24px; | ||
|
||
.split-view { | ||
display: flex; | ||
flex-direction: row; | ||
flex-grow: 1; | ||
|
||
.editor-wrap { | ||
display: flex; | ||
flex-direction: column; | ||
flex-grow: 1; | ||
|
||
gap: 10px; | ||
|
||
.sub-wrap { | ||
border: 1px solid var(--border-color); | ||
position: relative; | ||
flex-grow: 1; | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
.error { | ||
color: red; | ||
max-height: 50px; | ||
text-overflow: ellipsis; | ||
} | ||
|
||
|
||
|
||
ngx-monaco-editor { | ||
position: absolute; | ||
top: 0px; | ||
left: 0px; | ||
right: 0px; | ||
height: 100%; | ||
} | ||
} | ||
|
||
.flex-row { | ||
display: flex; | ||
flex-direction: row; | ||
gap: 24px; | ||
} | ||
|
||
.flex-column { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 5px; | ||
|
||
&.grow { | ||
flex-grow: 1; | ||
} | ||
|
||
&.gap-24 { | ||
gap: 24px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { TimeZonesComponent } from './time-zones.component'; | ||
|
||
describe('TimeZonesComponent', () => { | ||
let component: TimeZonesComponent; | ||
let fixture: ComponentFixture<TimeZonesComponent>; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [TimeZonesComponent] | ||
}); | ||
fixture = TestBed.createComponent(TimeZonesComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { HttpClient } from '@angular/common/http'; | ||
import { Component, inject, signal } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-time-zones', | ||
templateUrl: './time-zones.component.html', | ||
styleUrls: ['./time-zones.component.scss'] | ||
}) | ||
export class TimeZonesComponent { | ||
error = signal<string>(''); | ||
currentZone :TimeZone | any; | ||
covertToZone :TimeZone | any; | ||
zones: TimeZone[] = []; | ||
selectedTime = new Date(); | ||
currentTime = signal<string>(''); | ||
httpClient = inject(HttpClient); | ||
|
||
ZoneConversions: ZoneConversion[] = []; | ||
constructor() { | ||
this.loadData(); | ||
} | ||
loadData() | ||
{ | ||
this.httpClient.get<TimeZone[]>('./assets/json/timezones.json').subscribe((res) => { | ||
this.zones = res; | ||
this.currentZone = this.findZone(); | ||
this.covertToZone = this.findUTC(); | ||
console.log(new Date().toLocaleDateString(undefined, { day: '2-digit', timeZoneName: 'long' }).substring(4)); | ||
this.timeZoneChanged(); | ||
}); | ||
} | ||
findUTC() | ||
{ | ||
return this.zones.find((x: TimeZone) => x.value === 'UTC'); | ||
} | ||
findZone() { | ||
const myzone = Intl.DateTimeFormat().resolvedOptions().timeZone; | ||
for(const zone of this.zones) | ||
{ | ||
if (zone.utc.find((x: string) => x === myzone)) | ||
{ | ||
return zone; | ||
} | ||
} | ||
return null; | ||
} | ||
timeZoneChanged() { | ||
if (!this.currentZone) | ||
return; | ||
const time = this.selectedTime; | ||
|
||
const hour = time.getHours() - this.currentZone.offset; | ||
const today = new Date(); | ||
|
||
const ndate = new Date(today.getFullYear(), today.getMonth(), today.getDate(), hour, time.getMinutes(), time.getSeconds()); | ||
|
||
|
||
const lDate = time.toLocaleString("en-US", { timeZone: this.currentZone.utc[0], weekday: "long", year: "numeric", month: "2-digit", day: "numeric" }); | ||
const lTime = time.toLocaleTimeString("en-US", { timeZone: this.currentZone.utc[0], hour12: false, hour: 'numeric', minute: '2-digit' }); | ||
|
||
|
||
const tDate = ndate.toLocaleString("en-US", { timeZone: this.currentZone.utc[0], weekday: "long", year: "numeric", month: "2-digit", day: "numeric" }); | ||
const tTime = ndate.toLocaleTimeString("en-US", { timeZone: this.currentZone.utc[0], hour12: false, hour: 'numeric', minute: '2-digit' }); | ||
|
||
|
||
|
||
this.currentTime.set('From :' + lDate + " "+ lTime + " To: " + tDate + " " + tTime); | ||
|
||
|
||
|
||
} | ||
btnSwitch() | ||
{ | ||
const temp = this.currentZone; | ||
this.currentZone = this.covertToZone; | ||
this.covertToZone = temp; | ||
this.timeZoneChanged(); | ||
} | ||
} | ||
|
||
export interface ZoneConversion{ | ||
fromZone: TimeZone | any; | ||
toZone: TimeZone | any; | ||
date: Date; | ||
} | ||
export interface TimeZone { | ||
value: string; | ||
abbr: string; | ||
offset: number; | ||
isdst: boolean; | ||
text: string; | ||
utc: string[]; | ||
} |
Oops, something went wrong.