An unofficial TypeScript client for getfullyear.com that helps you get the full year. Because sometimes you just need to know what year it is, and you need to know it properly.
- Written in TypeScript with full type definitions
- Zero dependencies
- Supports both ESM and CommonJS
- Tiny bundle size
- Simple, clean API
- Promise-based for modern JavaScript applications
Using npm:
npm install get-full-year
Using yarn:
yarn add get-full-year
Using pnpm:
pnpm add get-full-year
import getFullYear from "get-full-year";
// Using async/await
const main = async () => {
const data = await getFullYear();
console.log(data);
};
// Using promises
getFullYear().then((data) => {
console.log(data);
});
const getFullYear = require("get-full-year").default;
getFullYear().then((data) => {
console.log(data);
});
Makes a sophisticated request to getfullyear.com's API to fetch the current year data, with optional enterprise mode support.
Parameters:
-
isEnterprise
(optional): boolean - Enables enterprise mode, suppressing sponsorship messages
Returns: Promise<YearResponseDTO>
- A promise that resolves with the year data.
Throws: YearFetchingError
- When the temporal data acquisition fails
Types:
interface YearResponseDTO {
year: number;
sponsored_by?: string;
metadata?: Record<string, unknown>;
}
Example:
// Standard mode
const yearData = await getFullYear();
console.log(yearData.year); // 2024
// Enterprise mode
const enterpriseData = await getFullYear(true);
Error Handling:
try {
const yearData = await getFullYear();
} catch (error) {
if (error instanceof YearFetchingError) {
console.error("Failed to acquire year:", error.message);
}
}
get-full-year/
├── src/ # Source code
├── dist/ # Compiled output
│ ├── esm/ # ES Modules
│ └── commonjs/ # CommonJS modules
├── example/ # Usage examples
└── .tshy/ # TypeScript build configuration
- Clone the repository
git clone https://github.com/threepointone/get-full-year.git
- Install dependencies
npm install
- Build the project
npm run prepare
This project uses tshy
for TypeScript builds, supporting both ESM and CommonJS output formats. The TypeScript configuration is split across multiple files:
-
tsconfig.json
: Base TypeScript configuration -
.tshy/build.json
: Shared build configuration -
.tshy/esm.json
: ESM-specific configuration -
.tshy/commonjs.json
: CommonJS-specific configuration
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
This project is licensed under the ISC License - see the LICENSE file for details.
Sunil Pai
- Email: threepointone@gmail.com
- GitHub: @threepointone
- Thanks to getfullyear.com for providing this essential service
- The TypeScript team for making type-safe JavaScript possible
- The open-source community for continuous inspiration
Made with ❤️ and probably too much coffee ☕️