Skip to content

using this api, you can easily have features of time.ir. don't forget stars :)

License

Notifications You must be signed in to change notification settings

mGolestan/time.ir

Repository files navigation

time.ir

This is an easy-to-use api for iranian offcial date-time website (Time.ir), Which gives you all features of it. Follow this readme for more info.

Table of contents

API Documentation

There's a table of api routes below

Method Route Required Params Description More Example Calls
GET / - Application healCheck route, it also check availability of time.ir at first Click
GET /datetime - Returns current time, with 3 seperate dates [Shamsi, gregorian, Hijri] Click Click
GET /events [year, month, day] Returns an array of events related to that day. Note: all parameters for this routes should be shamsi. Click Click
GET /events/month [year, month] Returns an array of events related to requested month. Note: all parameters for this routes should be in shamsi. Click Click
GET /convert [year, month, day, type] Returns a converted date based on entered value of type. accepted values for type are [jalali, gregorian, hijri]. Attention: type parameter should matches you other params. means that if yeah,month,day is in jalali type should be jalali as well. Click Click
GET /azan/times [province, city] Returns Azan times based on the requested city. keys number for each city and province can be found on /azan/cities route. Click Click
GET /cities - Returns cities and province names and keys. which should use the keys to get Azan times for a city Click Click

Getting started

In order to install this repository in your local envirement or server, you just need to do commen things like what you do on the other js repositories.
Here we use nvm for switching the node version to the repository required node version. And we use yarn instead of npm.

$ git clone https://github.com/mGolestan/time.ir.git
$ nvm use
$ yarn

When the node_modules installed, next step is to run repository based on your need. (development or production) Fore the development evirement you just need to cd to the repo directory and run in using below command

$ yarn start:dev

Production Use

While you are using this repo you have to be updated with the last version of it, because something in time.ir might change and this repo should update as well as time.ir changes. Basically for running this for production usage there's an script that can help you with that, but before it the env vars should update. So, first we need a copy of .env with this name .env.production.local. use this commad while you're in the root of repo to copy .env file

$ cp .env .env.production.local

Then here you can edit variable of the new file. for production use it is highly suggested to alter then NODE_ENV to production. There are 2 more vars that specify log level for winston module. More details about winston log level Now just run below command to build all files (which will copy to dist directory in the root of repo) for production use.

$ yarn build

Then here you can run this repository on your own server for production. We recommend pm2 process manager for Node.js, which you can easily findout how to work with it HERE, though I have written a simple usage of pm2 below

$ yarn add pm2 -g
or
$ npm install -g pm2
then
$ pm2 start dist/index.js --name="a name"

Feel free to Contribute.