Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit ca272df

Browse files
committed
Merge branch 'control_errors'
2 parents 1405084 + 7f3addb commit ca272df

File tree

23 files changed

+128
-186
lines changed

23 files changed

+128
-186
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
## Announcement
2+
Consider to nominate this plugin for the [Obsidian Community Plugin Contest](https://airtable.com/shrMd4Dj4oLgL55yt)!
13
## Database folder plugin
24
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/RafaelGB/obsidian-db-folder?style=for-the-badge&sort=semver)](https://github.com/RafaelGB/obsidian-db-folder/releases/latest)
35
[![Github All Releases](https://img.shields.io/github/downloads/RafaelGB/obsidian-db-folder/total?style=for-the-badge)]()

src/automations/core/modules/LuxonFn.ts

Lines changed: 0 additions & 51 deletions
This file was deleted.

src/cdm/ModulesFnModel.ts

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,74 @@
11
import { Literal } from "obsidian-dataview"
22
import { DateTime, DurationLikeObject } from "luxon";
33

4-
type NumbersFnType = {
4+
export interface NumbersInterface {
55
/**
66
* Summatory of the list of values
77
* @param values
88
* @returns
99
*/
1010
sum: (values: Literal[]) => number;
11+
1112
/**
1213
* Obtains the minimum value of the list of values
1314
* @param values
1415
* @returns
1516
*/
1617
min: (values: Literal[]) => number;
18+
1719
/**
1820
* Obtains the maximum value of the list of values
1921
* @param values
2022
* @returns
2123
*/
2224
max: (values: Literal[]) => number;
23-
[key: string]: unknown
2425
}
2526

26-
type LuxonFnType = {
27+
export interface LuxonInterface {
2728
/**
2829
* Returns the earliest date in the list of values
2930
* @param values
3031
* @returns
3132
*/
3233
earliest: (values: Literal[]) => DateTime;
34+
3335
/**
3436
* Returns the latest date in the list of values
3537
* @param values
3638
* @returns
3739
*/
3840
latest: (values: Literal[]) => DateTime;
41+
3942
/**
4043
* Returns the duration between the earliest and latest dates in the list of values
4144
* @param values
4245
* @param dl - Duration like object key. "days" by default. See https://www.jsdocs.io/package/@types/luxon#DurationLikeObject
4346
* @returns
4447
*/
4548
range: (values: Literal[], dl?: keyof DurationLikeObject) => number;
46-
[key: string]: unknown
49+
50+
/**
51+
* Parse datetime to string under a given format
52+
* @param datetime
53+
* @param format - Default: yyyy-MM-dd HH:mm:ss
54+
* @returns
55+
*/
56+
dateToString: (datetime: DateTime, format?: string) => string;
57+
58+
/**
59+
* Parse string to datetime under a given format
60+
* @param datetime
61+
* @param format - Default: yyyy-MM-dd HH:mm:ss
62+
* @returns
63+
*/
64+
stringToDate(datetime: string, format?: string): DateTime;
4765
}
4866

4967
/**
5068
* Exposed functionalities under the `db` variable of Formulas
5169
*/
5270
export type DatabaseFnType = {
53-
numbers: NumbersFnType;
54-
luxon: LuxonFnType;
71+
numbers: NumbersInterface;
72+
luxon: LuxonInterface;
5573
[key: string]: unknown
5674
}

src/components/DefaultFooter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Footer from "automations/Footer";
1+
import Footer from "lib/Footer";
22
import { DatabaseHeaderProps, TableColumn } from "cdm/FolderModel";
33
import { FooterType } from "helpers/Constants";
44
import React, { MouseEventHandler, useEffect, useState } from "react";

src/components/cellTypes/CalendarCell.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import { TableColumn } from "cdm/FolderModel";
1313
import { ParseService } from "services/ParseService";
1414
import { DEFAULT_SETTINGS, InputType } from "helpers/Constants";
1515
import { Platform } from "obsidian";
16-
import { parseLuxonDateToString } from "helpers/LuxonHelper";
1716
import { OBSIDIAN_LOCALE } from "lang/helpers";
17+
import { Db } from "services/CoreService";
1818

1919
const CalendarCell = (calendarProps: CellComponentProps) => {
2020
const { defaultCell } = calendarProps;
@@ -111,7 +111,7 @@ const CalendarCell = (calendarProps: CellComponentProps) => {
111111
}}
112112
tabIndex={0}
113113
>
114-
{parseLuxonDateToString(
114+
{Db.coreFns.luxon.dateToString(
115115
calendarCell,
116116
configInfo.getLocalSettings().date_format
117117
)}

src/components/cellTypes/CalendarTimeCell.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import { ParseService } from "services/ParseService";
1313
import { DEFAULT_SETTINGS, InputType } from "helpers/Constants";
1414
import { c } from "helpers/StylesHelper";
1515
import { Platform } from "obsidian";
16-
import { parseLuxonDatetimeToString } from "helpers/LuxonHelper";
1716
import { OBSIDIAN_LOCALE } from "lang/helpers";
17+
import { Db } from "services/CoreService";
1818

1919
const CalendarTimeCell = (calendarTimeProps: CellComponentProps) => {
2020
const { defaultCell } = calendarTimeProps;
@@ -112,7 +112,7 @@ const CalendarTimeCell = (calendarTimeProps: CellComponentProps) => {
112112
}}
113113
tabIndex={0}
114114
>
115-
{parseLuxonDatetimeToString(
115+
{Db.coreFns.luxon.dateToString(
116116
calendarCell,
117117
configInfo.getLocalSettings().datetime_format
118118
)}

src/helpers/LuxonHelper.ts

Lines changed: 0 additions & 75 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { FormulaFunctions } from "automations/formula_functions/FormulaFunctions";
2-
import { IGenerateObject } from "automations/core/IGenerateObject";
1+
import { FormulaFunctions } from "lib/formula_functions/FormulaFunctions";
2+
import { IGenerateObject } from "lib/core/IGenerateObject";
33
import { LocalSettings } from "cdm/SettingsModel";
44
export class FormulaGenerator implements IGenerateObject {
55
public js_functions: FormulaFunctions;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IGenerateObject } from "automations/core/IGenerateObject";
1+
import { IGenerateObject } from "lib/core/IGenerateObject";
22
import { DatabaseFnType } from "cdm/ModulesFnModel";
33
import { DbModule } from "./core/DbModule";
44
import { LuxonFn } from "./core/modules/LuxonFn";

0 commit comments

Comments
 (0)