Skip to content

Commit

Permalink
changed modules
Browse files Browse the repository at this point in the history
  • Loading branch information
timothydodd committed Oct 1, 2023
1 parent 00609bd commit 3992165
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 22 deletions.
26 changes: 21 additions & 5 deletions src/app/_services/route.service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Routes } from "@angular/router";
import { Type } from "@angular/core";
import { DefaultExport, Routes } from "@angular/router";
import { Observable } from "rxjs";
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{
Expand All @@ -15,12 +16,17 @@ export class RouteService{
{
for (const route of c.routes)
{
if (route.loadComponent)
{
routes.push({ path: route.url.substring(1), pathMatch: 'full', loadComponent: route.loadComponent });
}else{
routes.push({ path: route.url.substring(1), pathMatch: 'full', component: route.component });
}
}
}
return routes;
}
public static routeCategories = [
public static routeCategories: RouteCategory[] = [
{
name: 'Formatters',
routes: [
Expand All @@ -31,14 +37,24 @@ export class RouteService{
{
name: 'Converters',
routes: [
{ name: 'Json To Yaml', url: '/convert/json-yaml', component: CJsonYamlComponent },
{ name: 'Json To Yaml', url: '/convert/json-yaml', component: CJsonYamlComponent},
]
},
{
name: 'Time',
routes: [
{ name: 'Time Zones', url: '/time/zones', component: TimeZonesComponent },
{ name: 'Time Zones', url: '/time/zones', loadComponent: () => import('../time/time-zones/time-zones.component').then(mod => mod.TimeZonesComponent)},
]
}
]
}
export interface RouteCategory{
name:string | any;
routes: UpRoute[];
}
export interface UpRoute{
name: string | any;
url: string | any;
component?: Type<any>;
loadComponent?: () => Type<unknown> | Observable<Type<unknown> | DefaultExport<Type<unknown>>> | Promise<Type<unknown> | DefaultExport<Type<unknown>>>;
}
15 changes: 5 additions & 10 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { HttpClientModule } from '@angular/common/http';

import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgSelectModule } from '@ng-select/ng-select';
import { TimepickerModule } from 'ngx-bootstrap/timepicker';

import { MonacoEditorModule } from 'ngx-monaco-editor-v2';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
Expand All @@ -27,19 +26,15 @@ import { TimeZonesComponent } from './time/time-zones/time-zones.component';
FJsonComponent,
FYamlComponent,
CJsonYamlComponent,
ConvertViewComponent,
TimeZonesComponent,

ConvertViewComponent,
],
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule,
TimepickerModule.forRoot(),
FormsModule,
NgSelectModule,
MonacoEditorModule.forRoot(new MonacoEditorConfig()),
BrowserAnimationsModule
BrowserAnimationsModule,
TimeZonesComponent
],
bootstrap: [AppComponent]
})
Expand Down
2 changes: 1 addition & 1 deletion src/app/time/time-zones/time-zones.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<h1>Time Zone Conversions</h1>
<timepicker [(ngModel)]="selectedTime"></timepicker>
<timepicker [(ngModel)]="selectedTime" (ngModelChange)="timeZoneChanged()"></timepicker>
<div class="flex-row">
<button class="btn btn-secondary" (click)="btnSwitch()">Switch</button>
<div class="flex-column grow gap-24">
Expand Down
22 changes: 16 additions & 6 deletions src/app/time/time-zones/time-zones.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import { HttpClient } from '@angular/common/http';
import { CommonModule } from '@angular/common';
import { HttpClient, HttpClientModule } from '@angular/common/http';
import { Component, inject, signal } from '@angular/core';

import { FormsModule } from '@angular/forms';
import { NgSelectModule } from '@ng-select/ng-select';
import { TimepickerModule } from 'ngx-bootstrap/timepicker';
@Component({
selector: 'app-time-zones',
templateUrl: './time-zones.component.html',
styleUrls: ['./time-zones.component.scss']
styleUrls: ['./time-zones.component.scss'],
standalone: true,
imports: [
CommonModule,
NgSelectModule,
FormsModule,
HttpClientModule,
TimepickerModule]
})
export class TimeZonesComponent {
error = signal<string>('');
Expand Down Expand Up @@ -54,13 +64,13 @@ export class TimeZonesComponent {

const ndate = new Date(today.getFullYear(), today.getMonth(), today.getDate(), hour, time.getMinutes(), time.getSeconds());


ndate.setHours(ndate.getHours() + this.covertToZone.offset);
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' });
const tDate = ndate.toLocaleString("en-US", { timeZone: this.covertToZone.utc[0], weekday: "long", year: "numeric", month: "2-digit", day: "numeric" });
const tTime = ndate.toLocaleTimeString("en-US", { timeZone: this.covertToZone.utc[0], hour12: false, hour: 'numeric', minute: '2-digit' });



Expand Down

0 comments on commit 3992165

Please sign in to comment.