From fba99f79cad959a248a09c72411544197cd191e1 Mon Sep 17 00:00:00 2001 From: Nirab Pudasaini Date: Wed, 6 Sep 2017 16:34:17 +0545 Subject: [PATCH] Added days strings --- .../BSCalender/NepaliDate.java | 33 ++++++++++++++++--- src/main/res/values-ne/strings.xml | 7 ++++ src/main/res/values/strings.xml | 7 ++++ 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/main/java/np/com/nirab/nepalideveloperutils/BSCalender/NepaliDate.java b/src/main/java/np/com/nirab/nepalideveloperutils/BSCalender/NepaliDate.java index 5e7d942..e804510 100644 --- a/src/main/java/np/com/nirab/nepalideveloperutils/BSCalender/NepaliDate.java +++ b/src/main/java/np/com/nirab/nepalideveloperutils/BSCalender/NepaliDate.java @@ -14,7 +14,7 @@ public class NepaliDate { private int mYear, mMonth, mDayOfMonth, mDayofWeek, mHourOfDay, mMinute, mSecond, mMillisecond; - private String mMonthString; + private String mMonthString, mDayString; private Context mContext; HashMap daysInMonths = new HashMap<>(); @@ -133,7 +133,6 @@ public void init(DateTime date){ daysInMonths.put(2090, new int[]{30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30}); DateTime base = new DateTime(1944,1,1,0,0); - date = date.withZone(DateTimeZone.forID("Asia/Kathmandu")); long daysBetween = Days.daysBetween(base,date).getDays(); @@ -165,6 +164,7 @@ public void init(DateTime date){ this.mMonthString = getMonthString(nepaliMonth); this.mDayOfMonth = nepaliDay; this.mDayofWeek = dayOfWeek; + this.mDayString = getDayString(dayOfWeek); this.mHourOfDay = date.getHourOfDay(); this.mMinute = date.getMinuteOfHour(); this.mSecond = date.getSecondOfMinute(); @@ -202,6 +202,29 @@ public String getMonthString(int month){ } } + public String getDayString(int day){ + switch (day){ + case 1: + return mContext.getString(R.string.ndu_sunday); + case 2: + return mContext.getString(R.string.ndu_monday); + case 3: + return mContext.getString(R.string.ndu_tuesday); + case 4: + return mContext.getString(R.string.ndu_wednesday); + case 5: + return mContext.getString(R.string.ndu_thrusday); + case 6: + return mContext.getString(R.string.ndu_friday); + case 7: + return mContext.getString(R.string.ndu_saturday); + default: + return "Error"; + } + } + + + public int getYear() { return mYear; } @@ -226,11 +249,11 @@ public void setDayOfMonth(int mDayOfMonth) { this.mDayOfMonth = mDayOfMonth; } - public int getDayofWeek() { + public int getDayOfWeek() { return mDayofWeek; } - public void setDayofWeek(int mDayofWeek) { + public void setDayOfWeek(int mDayofWeek) { this.mDayofWeek = mDayofWeek; } @@ -266,4 +289,6 @@ public void setMillisecond(int mMillisecond) { this.mMillisecond = mMillisecond; } + + } \ No newline at end of file diff --git a/src/main/res/values-ne/strings.xml b/src/main/res/values-ne/strings.xml index d939889..ee203d4 100644 --- a/src/main/res/values-ne/strings.xml +++ b/src/main/res/values-ne/strings.xml @@ -13,4 +13,11 @@ मंसिर पुष श्रावण + आइतबार + सोमबार + मंगलबार + बुधबार + बिहिबार + शुक्रबार + शनिबार \ No newline at end of file diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 0933f51..7b1467c 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -12,5 +12,12 @@ Magh Falgun Chaitra + Aaitabaar + Sombaar + Mangalbaar + Budhabaar + Bihibaar + Shukrabaar + Shanibaar