Skip to content

Commit

Permalink
fix: add 24h switch and bugs fixes
Browse files Browse the repository at this point in the history
Fixes Timezones <> Countries reactivity
Fix current timezone field to be readonlt
Added 24h format switch
  • Loading branch information
sharevb committed Sep 13, 2024
1 parent c68388f commit 5fee8aa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
14 changes: 4 additions & 10 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,29 +130,22 @@ declare module '@vue/runtime-core' {
MetaTagGenerator: typeof import('./src/tools/meta-tag-generator/meta-tag-generator.vue')['default']
MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default']
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
NButton: typeof import('naive-ui')['NButton']
NCode: typeof import('naive-ui')['NCode']
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
NDatePicker: typeof import('naive-ui')['NDatePicker']
NDivider: typeof import('naive-ui')['NDivider']
NDynamicInput: typeof import('naive-ui')['NDynamicInput']
NEllipsis: typeof import('naive-ui')['NEllipsis']
NForm: typeof import('naive-ui')['NForm']
NFormItem: typeof import('naive-ui')['NFormItem']
NH1: typeof import('naive-ui')['NH1']
NH3: typeof import('naive-ui')['NH3']
NIcon: typeof import('naive-ui')['NIcon']
NImage: typeof import('naive-ui')['NImage']
NInput: typeof import('naive-ui')['NInput']
NInputGroup: typeof import('naive-ui')['NInputGroup']
NInputGroupLabel: typeof import('naive-ui')['NInputGroupLabel']
NInputNumber: typeof import('naive-ui')['NInputNumber']
NLayout: typeof import('naive-ui')['NLayout']
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
NMenu: typeof import('naive-ui')['NMenu']
NScrollbar: typeof import('naive-ui')['NScrollbar']
NSelect: typeof import('naive-ui')['NSelect']
NSlider: typeof import('naive-ui')['NSlider']
NSpace: typeof import('naive-ui')['NSpace']
NStatistic: typeof import('naive-ui')['NStatistic']
NSwitch: typeof import('naive-ui')['NSwitch']
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default']
Expand Down Expand Up @@ -180,6 +173,7 @@ declare module '@vue/runtime-core' {
TextStatistics: typeof import('./src/tools/text-statistics/text-statistics.vue')['default']
TextToBinary: typeof import('./src/tools/text-to-binary/text-to-binary.vue')['default']
TextToNatoAlphabet: typeof import('./src/tools/text-to-nato-alphabet/text-to-nato-alphabet.vue')['default']
TextToUnicode: typeof import('./src/tools/text-to-unicode/text-to-unicode.vue')['default']
TimezoneConverter: typeof import('./src/tools/timezone-converter/timezone-converter.vue')['default']
TokenDisplay: typeof import('./src/tools/otp-code-generator-and-validator/token-display.vue')['default']
'TokenGenerator.tool': typeof import('./src/tools/token-generator/token-generator.tool.vue')['default']
Expand Down
16 changes: 12 additions & 4 deletions src/tools/timezone-converter/timezone-converter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ function convertMinsToHrsMins(minutes: number) {
const otherTimezones = useStorage<{ name: string }[]>('timezone-conv:zones', [{ name: 'Etc/GMT' }]);
const currentTimezone = useStorage<string>('timezone-conv:current', browserTimezone);
const use24HourTimeFormat = useStorage<boolean>('timezone-conv:24h', true);

Check failure on line 19 in src/tools/timezone-converter/timezone-converter.vue

View workflow job for this annotation

GitHub Actions / ci

Expected indentation of 0 spaces but found 2

Check failure on line 20 in src/tools/timezone-converter/timezone-converter.vue

View workflow job for this annotation

GitHub Actions / ci

Trailing spaces not allowed
const now = Date.now();
const currentDatetimeRange = ref<[number, number]>([now, now]);
const currentTimezoneOffset = computed(() => {
Expand All @@ -27,7 +29,7 @@ function convertToTimezone(tz: string, timestamp: number) {
+ getTimezoneOffset(currentTimezone.value, new Date()) * 60 * 1000
- getTimezoneOffset(browserTimezone, new Date()) * 60 * 1000,
).toLocaleString(undefined,
{ timeZone: tz, timeZoneName: undefined, hour12: false });
{ timeZone: tz, timeZoneName: undefined, hour12: !use24HourTimeFormat.value });
}
const tzToCountriesInput = ref(browserTimezone);
Expand Down Expand Up @@ -58,12 +60,18 @@ const countryToTimezonesOutput = computed(() => ctz.getTimezonesForCountry(count
mb-2
/>

<input-copyable
<n-space justify="space-evenly">
<input-copyable
label="Current Timezone Offset (min)"

Check warning on line 65 in src/tools/timezone-converter/timezone-converter.vue

View workflow job for this annotation

GitHub Actions / ci

Expected indentation of 10 spaces but found 8 spaces
label-position="left"

Check warning on line 66 in src/tools/timezone-converter/timezone-converter.vue

View workflow job for this annotation

GitHub Actions / ci

Expected indentation of 10 spaces but found 8 spaces
:value="currentTimezoneOffset"

Check warning on line 67 in src/tools/timezone-converter/timezone-converter.vue

View workflow job for this annotation

GitHub Actions / ci

Expected indentation of 10 spaces but found 8 spaces
readonly

Check warning on line 68 in src/tools/timezone-converter/timezone-converter.vue

View workflow job for this annotation

GitHub Actions / ci

Expected indentation of 10 spaces but found 8 spaces
mb-2

Check warning on line 69 in src/tools/timezone-converter/timezone-converter.vue

View workflow job for this annotation

GitHub Actions / ci

Expected indentation of 10 spaces but found 8 spaces
/>

Check warning on line 70 in src/tools/timezone-converter/timezone-converter.vue

View workflow job for this annotation

GitHub Actions / ci

Expected indentation of 8 spaces but found 6 spaces
<n-form-item label="Use 24 hour time format" label-placement="left">
<n-switch v-model:value="use24HourTimeFormat" />
</n-form-item>
</n-space>

<c-card title="Date-Time in other timezones">
<n-dynamic-input
Expand Down Expand Up @@ -94,7 +102,7 @@ const countryToTimezonesOutput = computed(() => ctz.getTimezonesForCountry(count
<c-select
label="Country"
label-position="left"
:value="countryToTimezonesInput"
v-model:value="countryToTimezonesInput"

Check warning on line 105 in src/tools/timezone-converter/timezone-converter.vue

View workflow job for this annotation

GitHub Actions / ci

Attribute "v-model:value" should go before "label-position"
searchable
:options="allCountries"
/>
Expand All @@ -112,7 +120,7 @@ const countryToTimezonesOutput = computed(() => ctz.getTimezonesForCountry(count
<c-select
label="Timezone"
label-position="left"
:value="tzToCountriesInput"
v-model:value="tzToCountriesInput"

Check warning on line 123 in src/tools/timezone-converter/timezone-converter.vue

View workflow job for this annotation

GitHub Actions / ci

Attribute "v-model:value" should go before "label-position"
searchable
:options="allTimezones"
/>
Expand Down

0 comments on commit 5fee8aa

Please sign in to comment.