getReadableDate
30 return randDate.toISOString().split("T")[0];
31};
32
33export const getReadableDate = (dateString) => {34 const dateObject = new Date(dateString);
35 const options = { year: "numeric", month: "long", day: "numeric" };
36 const dateTimeFormat = new Intl.DateTimeFormat("en-US", options);
generateRandomDate
21 return `${year}-${month}-${day}`;
22};
23
24export const generateRandomDate = () => {25 const currentDate = new Date();
26 const startDate = new Date(1995, 6, 16);
27 const diffTime = currentDate - startDate;
changeDateFormat
7};
8
9
10export const changeDateFormat = (date) => {11 const dateArray = date.split("/");
12 const year = dateArray[2];
13 let month = dateArray[1];
currentDate
1export const currentDate = () => { 2 const date = new Date();
3 const day = date.getDate();
4 const month = date.getMonth() + 1;
searchAPOD
1
2const API_KEY = import.meta.env.VITE_API_KEY
3
4const searchAPOD = async ({queryKey}) => { 5 const date = queryKey[1];
6 const response = await fetch(
7 `https://api.nasa.gov/planetary/apod?api_key=${API_KEY}&date=${date}`
It is recommended to have documentation comments above, or right inside a function/class declaration. This helps developers, users and even the author understand the purpose of a code snippet or API function in the future.
NOTE: If you want to stop this issue from getting raised on certain constructs (arrow functions, class expressions, methods etc.), consider using the skipdoccoverage option under the analyzers.meta
property in your .deepsource.toml
file.
For example, the following configuration will silence this issue for class expressions and method definitions:
[analyzers.meta]
skip_doc_coverage = ["class-expression", "method-definition"]
function sum(a, b) {
return a + b;
}
/**
* Function to add two numbers
* @param a The first number to add
* @param b The second number to add
* @returns The sum of two numbers
*/
function sum(a, b) {
return a + b;
}