Skip to content

Latest commit

 

History

History
91 lines (66 loc) · 2.44 KB

README.md

File metadata and controls

91 lines (66 loc) · 2.44 KB

YaaS

Year as a Service. Providing you with extremely accurate year as an API service, since 2015.

Examples

Note that these examples may not take into account good security practices, for example escaping output to prevent XSS vulnerabilities.

PHP

<?php
$year = file_get_contents('https://raw.github.com/asgrim/year/master/en/currentYear');

echo $year; // 2025

Ruby

require 'net/http'
year = Net::HTTP.get_response(URI.parse("https://raw.github.com/asgrim/year/master/en/currentYear")).body
p year # 2025

Python

import urllib2
year = urllib2.urlopen('https://raw.github.com/asgrim/year/master/en/currentYear').read(1000).strip()
print year; # 2025

JavaScript

// Fetch
fetch('https://raw.githubusercontent.com/asgrim/year/master/en/currentYear')
    .then(resp => resp.json())
    .then(year => console.log(year)) // 2025

// XMLHttpRequest
let xhr = new XMLHttpRequest()
xhr.open('GET', 'https://raw.githubusercontent.com/asgrim/year/master/en/currentYear', true);
xhr.onload = () => {
    if (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) {
        console.log(xhr.responseText)
    }
};
xhr.send(); // 2020

Bash

#!/bin/bash
## Fetch
page="$(curl -s https://raw.githubusercontent.com/asgrim/year/master/en/currentYear)"
echo "$page" # 2025

BC Break

In the future, we may have to break BC by removing the root "currentYear". You should use "en/currentYear" instead.

Internationalisation (i18n)

YaaS also supports the following calendars:

Hebrew (he):

Chinese (zh-cn):

FAQs

Should I use this in my real application?

  • No.

r u troleing me?

  • Yes.