Browse files

Merge pull request #1 from travis4all/clean

The repo your repo could be like!
  • Loading branch information...
2 parents 812cc4c + e535857 commit 5a42e43640835da30a22f645eafaa3cf2ee8dc51 @alireza-ahmadi committed Aug 23, 2012
Showing with 140 additions and 135 deletions.
  1. +4 −0 .travis.yml
  2. +1 −0 README.md
  3. +12 −12 example/example.js
  4. +123 −123 index.js
View
4 .travis.yml
@@ -0,0 +1,4 @@
+language: node_js
+node_js:
+ - 0.6
+ - 0.8
View
1 README.md
@@ -1,3 +1,4 @@
+[![build status](https://secure.travis-ci.org/alireza-ahmadi/jalali.png)](http://travis-ci.org/alireza-ahmadi/jalali)
## Information
View
24 example/example.js
@@ -1,12 +1,12 @@
-var http = require('http');
-var Jalali = require('../index.js');
-
-http.createServer(function (req, res) {
- res.writeHead(200, {'Content-Type': 'text/plain'});
- var today = Jalali.today('alphabetic');
- var str = 'امروز ' + Jalali.persianDay() + '، ' + today.d + ' ' + today.m + ' ' + today.y;
- res.end(str);
-}).listen(9999);
-
-console.log('now : go to http://localhost:9999');
-
+var http = require('http');
+var Jalali = require('../index.js');
+
+http.createServer(function (req, res) {
+ res.writeHead(200, {'Content-Type': 'text/plain'});
+ var today = Jalali.today('alphabetic');
+ var str = 'امروز ' + Jalali.persianDay() + '، ' + today.d + ' ' + today.m + ' ' + today.y;
+ res.end(str);
+}).listen(9999);
+
+console.log('now : go to http://localhost:9999');
+
View
246 index.js
@@ -1,127 +1,127 @@
-/*
- * Jalali - Nodejs Jalali Calendar
- * By : Alireza Ahmadi | http://alireza.es
- * Special thanks to Ali Farhadi | http://farhadi.ir
- */
-var JalaliDate = require('./lib/jalaliDate.js'); // By Ali Farhadi
-
-var Jalali = {
- jmonths : ['فروردین','اردیبهشت','خرداد','تیر','مرداد','شهریور','مهر','آبان','آذر','دی','بهمن','اسفند'],
-
- jdays : ['دوشنبه','سه شنبه','چهارشنبه','پنجشنبه','جمعه','شنبه','یکشنبه'],
-
- alphabetic : function(month){
- return this.jmonths[month - 1];
- },
-
- persianDay : function(get){
- if(!get){
- var d = new Date();
- get = d.getDay();
- }
- return this.jdays[get - 1];
- },
-
- yesterday : function(style){
- var date = new Date();
- var jdate = {
- year : parseInt(date.getFullYear()),
- month : parseInt(date.getMonth() + 1),
- day : parseInt(date.getDate())
- }
- if(jdate.day == 1){
- if(jdate.month == 1){
- jdate.month = 12;
- jdate.year = jdate.year - 1;
- jdate.day = 29;
- }
- else{
- jdate.month = jdate.month - 1;
- jdate.day = JalaliDate.j_days_in_month[jdate.month - 2];
- }
- }
- else{
- jdate.day = jdate.day - 1;
- }
-
- jdate.result = JalaliDate.gregorianToJalali(jdate.year, jdate.month, jdate.day);
- if(style){
- jdate.result[1] = this.alphabetic(jdate.result[1]);
- }
- return this.list(jdate.result);
- },
-
- today : function(style){
- var date = new Date();
- var jdate = {
- year : parseInt(date.getFullYear()),
- month : parseInt(date.getMonth() + 1),
- day : parseInt(date.getDate())
- }
- jdate.result = JalaliDate.gregorianToJalali(jdate.year, jdate.month, jdate.day);
- if(style){
- jdate.result[1] = this.alphabetic(jdate.result[1]);
- }
- return this.list(jdate.result);
- },
-
- tomorrow : function(style){
- var date = new Date();
- var jdate = {
- year : parseInt(date.getFullYear()),
- month : parseInt(date.getMonth() + 1),
- day : parseInt(date.getDate())
- }
- if(jdate.day == JalaliDate.j_days_in_month[jdate.month - 1]){
- if(jdate.month == 12){
- jdate.month = 1;
- jdate.year = jdate.year + 1;
- jdate.day = 1;
- }
- else{
- jdate.month = jdate.month + 1;
- jdate.day = 1;
- }
- }
- else{
- jdate.day = jdate.day + 1;
- }
-
- jdate.result = JalaliDate.gregorianToJalali(jdate.year, jdate.month, jdate.day);
- if(style){
- jdate.result[1] = this.alphabetic(jdate.result[1]);
- }
- return this.list(jdate.result);
- },
-
+/*
+ * Jalali - Nodejs Jalali Calendar
+ * By : Alireza Ahmadi | http://alireza.es
+ * Special thanks to Ali Farhadi | http://farhadi.ir
+ */
+var JalaliDate = require('./lib/jalaliDate.js'); // By Ali Farhadi
+
+var Jalali = {
+ jmonths : ['فروردین','اردیبهشت','خرداد','تیر','مرداد','شهریور','مهر','آبان','آذر','دی','بهمن','اسفند'],
+
+ jdays : ['دوشنبه','سه شنبه','چهارشنبه','پنجشنبه','جمعه','شنبه','یکشنبه'],
+
+ alphabetic : function(month){
+ return this.jmonths[month - 1];
+ },
+
+ persianDay : function(get){
+ if(!get){
+ var d = new Date();
+ get = d.getDay();
+ }
+ return this.jdays[get - 1];
+ },
+
+ yesterday : function(style){
+ var date = new Date();
+ var jdate = {
+ year : parseInt(date.getFullYear()),
+ month : parseInt(date.getMonth() + 1),
+ day : parseInt(date.getDate())
+ }
+ if(jdate.day == 1){
+ if(jdate.month == 1){
+ jdate.month = 12;
+ jdate.year = jdate.year - 1;
+ jdate.day = 29;
+ }
+ else{
+ jdate.month = jdate.month - 1;
+ jdate.day = JalaliDate.j_days_in_month[jdate.month - 2];
+ }
+ }
+ else{
+ jdate.day = jdate.day - 1;
+ }
+
+ jdate.result = JalaliDate.gregorianToJalali(jdate.year, jdate.month, jdate.day);
+ if(style){
+ jdate.result[1] = this.alphabetic(jdate.result[1]);
+ }
+ return this.list(jdate.result);
+ },
+
+ today : function(style){
+ var date = new Date();
+ var jdate = {
+ year : parseInt(date.getFullYear()),
+ month : parseInt(date.getMonth() + 1),
+ day : parseInt(date.getDate())
+ }
+ jdate.result = JalaliDate.gregorianToJalali(jdate.year, jdate.month, jdate.day);
+ if(style){
+ jdate.result[1] = this.alphabetic(jdate.result[1]);
+ }
+ return this.list(jdate.result);
+ },
+
+ tomorrow : function(style){
+ var date = new Date();
+ var jdate = {
+ year : parseInt(date.getFullYear()),
+ month : parseInt(date.getMonth() + 1),
+ day : parseInt(date.getDate())
+ }
+ if(jdate.day == JalaliDate.j_days_in_month[jdate.month - 1]){
+ if(jdate.month == 12){
+ jdate.month = 1;
+ jdate.year = jdate.year + 1;
+ jdate.day = 1;
+ }
+ else{
+ jdate.month = jdate.month + 1;
+ jdate.day = 1;
+ }
+ }
+ else{
+ jdate.day = jdate.day + 1;
+ }
+
+ jdate.result = JalaliDate.gregorianToJalali(jdate.year, jdate.month, jdate.day);
+ if(style){
+ jdate.result[1] = this.alphabetic(jdate.result[1]);
+ }
+ return this.list(jdate.result);
+ },
+
convert : function(fyear,fmonth,fday,format,style){
- var jdate = {
- year : fyear,
- month : fmonth,
- day : fday
- }
- var type = format || 'gj' ;
- if(type == 'gj'){
- jdate.result = JalaliDate.gregorianToJalali(jdate.year, jdate.month, jdate.day);
- if(style){
- jdate.result[1] = this.alphabetic(jdate.result[1]);
- }
- }
- else if(type == 'jg'){
- jdate.result = JalaliDate.jalaliToGregorian(jdate.year, jdate.month, jdate.day);
- }
+ var jdate = {
+ year : fyear,
+ month : fmonth,
+ day : fday
+ }
+ var type = format || 'gj' ;
+ if(type == 'gj'){
+ jdate.result = JalaliDate.gregorianToJalali(jdate.year, jdate.month, jdate.day);
+ if(style){
+ jdate.result[1] = this.alphabetic(jdate.result[1]);
+ }
+ }
+ else if(type == 'jg'){
+ jdate.result = JalaliDate.jalaliToGregorian(jdate.year, jdate.month, jdate.day);
+ }
return this.list(jdate.result);
- },
-
- list : function(get){
- var answer = {
- y : get[0],
- m : get[1],
- d : get[2]
- }
- return answer;
- }
+ },
+
+ list : function(get){
+ var answer = {
+ y : get[0],
+ m : get[1],
+ d : get[2]
+ }
+ return answer;
+ }
}
-
-module.exports = Jalali;
+
+module.exports = Jalali;

0 comments on commit 5a42e43

Please sign in to comment.