https://github.com/threepointone/get-full-year
A client for getfullyear.com
https://github.com/threepointone/get-full-year
Last synced: 29 days ago
JSON representation
A client for getfullyear.com
- Host: GitHub
- URL: https://github.com/threepointone/get-full-year
- Owner: threepointone
- License: other
- Created: 2025-01-01T22:27:09.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-01-01T22:47:50.000Z (5 months ago)
- Last Synced: 2025-04-04T16:42:37.316Z (about 2 months ago)
- Language: TypeScript
- Size: 29.3 KB
- Stars: 32
- Watchers: 1
- Forks: 3
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# get-full-year 🗓️
[](https://badge.fury.io/js/get-full-year)
[](https://opensource.org/licenses/ISC)An unofficial TypeScript client for [getfullyear.com](https://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_.
## 🚀 Features
- 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## 📦 Installation
Using npm:
```bash
npm install get-full-year
```Using yarn:
```bash
yarn add get-full-year
```Using pnpm:
```bash
pnpm add get-full-year
```## 🔨 Usage
### ESM
```typescript
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);
});
```### CommonJS
```javascript
const getFullYear = require("get-full-year").default;getFullYear().then((data) => {
console.log(data);
});
```## 🔍 API Reference
### `getFullYear(isEnterprise?: boolean)`
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` - A promise that resolves with the year data.
**Throws**: `YearFetchingError` - When the temporal data acquisition fails
**Types**:
```typescript
interface YearResponseDTO {
year: number;
sponsored_by?: string;
metadata?: Record;
}
```**Example**:
```typescript
// Standard mode
const yearData = await getFullYear();
console.log(yearData.year); // 2024// Enterprise mode
const enterpriseData = await getFullYear(true);
```**Error Handling**:
```typescript
try {
const yearData = await getFullYear();
} catch (error) {
if (error instanceof YearFetchingError) {
console.error("Failed to acquire year:", error.message);
}
}
```## 🏗️ Project Structure
```
get-full-year/
├── src/ # Source code
├── dist/ # Compiled output
│ ├── esm/ # ES Modules
│ └── commonjs/ # CommonJS modules
├── example/ # Usage examples
└── .tshy/ # TypeScript build configuration
```## 🛠️ Development
1. Clone the repository
```bash
git clone https://github.com/threepointone/get-full-year.git
```2. Install dependencies
```bash
npm install
```3. Build the project
```bash
npm run prepare
```## 📝 TypeScript Configuration
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## 🤝 Contributing
Contributions, issues, and feature requests are welcome! Feel free to check the [issues page](https://github.com/threepointone/get-full-year/issues).
## 📄 License
This project is licensed under the ISC License - see the [LICENSE](LICENSE) file for details.
## 👤 Author
**Sunil Pai**
- Email: [email protected]
- GitHub: [@threepointone](https://github.com/threepointone)## 🙏 Acknowledgments
- Thanks to [getfullyear.com](https://getfullyear.com) for providing this essential service
- The TypeScript team for making type-safe JavaScript possible
- The open-source community for continuous inspiration## 📊 Stats

---
Made with ❤️ and probably too much coffee ☕️