jalaali / moment-jalaali

A Jalaali (Jalali, Persian, Khorshidi, Shamsi) calendar system plugin for moment.js.
MIT License
939 stars 162 forks source link

how get start and end current week #255

Open mohsenmehri6101 opened 1 year ago

mohsenmehri6101 commented 1 year ago

how can get the stat and end from current week.

example if today is 1402-06-18 (سه شنبه) get :
start : 1402-06-15 end : 1402-06-21 ???

mohsenmehri6101 commented 1 year ago

@behrang

ngtive commented 1 year ago

@mohsenmehri6101

const startOfCurrentWeek = moment().startOf("week").startOf("day") const endOfCurrentWeek = moment().endOf("week").endOf("day")

mohsenmehri6101 commented 1 year ago

@ngtive thanks for your answer .but this code get start week georgian (sunday) . but should be get saterday. and too about end week.

behrang commented 1 year ago

If I remember correctly, week start day has no relation to the calendar system. I think in moment, you can change week start day or set it using a locale. Then you can do the calculations that you want.

1mehdifaraji commented 8 months ago

@mohsenmehri6101 You can get the jalaali calendar start and end of the week like this:

moment().locale("fa").startOf("jWeek").format("jYYYY/jMM/jDD");
moment().locale("fa").endOf("jWeek").format("jYYYY/jMM/jDD");