Skip to content

davoudarsalani/action-jdate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 

Repository files navigation

Download/install the latest version of jdate

last-commit commit-activity

Jalali Calendar, developed by Ashkan Ghassemi, is:

... a small and portable free software library to manipulate date and time in Jalali calendar system.



- name: Installing jdate
  uses: davoudarsalani/action-jdate@master
  with:
    source: 'docker-jdate'  ## default

There are ten options for source:

  • Use docker image
    • docker-khayyam will pull khayyam docker image/repository (about 61.3MB in size) containing khayyam python module on Alpine Linux
    • docker-persiantools will pull persiantools docker image/repository (about 60.8MB in size) containing persiantools python module on Alpine Linux
    • docker-jdatetime will pull jdatetime docker image/repository (about 59.8MB in size) containing jdatetime python module on Alpine Linux
    • docker-jdate will pull jdate docker image/repository (about 8.22MB in size) containing jdate on Alpine Linux
  • Download tar.gz file
    • askapache will download from askapache.com
    • gnu will download from gnu.org
    • nongnu will download from nongnu.org
  • Clone git repository
    • clone-github will clone from github.com
    • clone-gnu will clone from gnu.org
    • clone-nongnu will clone from nongnu.org

For docker-khayyam, docker-persiantools or docker-jdatetime set as source, you may use either of the following commands respectively to set date/time:

## docker-khayyam
run: date_time="$(docker run --rm -t davoudarsalani/khayyam \
       python -c "import khayyam; print(khayyam.JalaliDatetime.now().strftime('%Y-%m-%d %H:%M:%S %A'))")"

## docker-persiantools
run: date_time="$(docker run --rm -t davoudarsalani/persiantools \
       python -c "from persiantools.jdatetime import JalaliDateTime; print(JalaliDateTime.now().strftime('%Y-%m-%d %H:%M:%S %A'))")"

## docker-jdatetime
run: date_time="$(docker run --rm -t davoudarsalani/jdatetime \
       python -c "import jdatetime; print(jdatetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S %A'))")"

Note: These three options, as mentioned earlier, use respective python modules.
The documents state that we can use the same format used for the datetime module:

khayyam: The package’s API is considered to be exactly the same as the datetime module, so if you are familiar with the datetime, you can read the Migration from python’s builtin datetime.

persiantools: Jalali (Shamsi) date and datetime (based on python datetime's module)

jdatetime: This module exactly follows Python Standard datetime module’s methods


Alternatively, if docker-jdate is set for source, you can use jdate command to get date/time:

- name: Getting date/time
  shell: bash
  run: date_time="$(docker run --rm -t davoudarsalani/jdate jdate '+%Y-%m-%d %H:%M:%S %A')"

Similarly, if the other options are chosen, you can use jdate command:

run: date_time="$(jdate '+%Y-%m-%d %H:%M:%S %A')"

Note: jdate and date share the same format.