Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/475.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Airbnb使用非英语区域设置的日期日历_Javascript_Reactjs_React Dates - Fatal编程技术网

Javascript Airbnb使用非英语区域设置的日期日历

Javascript Airbnb使用非英语区域设置的日期日历,javascript,reactjs,react-dates,Javascript,Reactjs,React Dates,我正在尝试使用非英语语言环境(波斯语),一切都很好,除了一个月的第一天 月份不是从波斯语(Jalaali)日历的第一天开始到第30天,而是从每月的第10天开始,一直持续到下个月的第10天 这个问题甚至存在于他们的生活中。我想知道是否有办法解决这个问题。我一直在一个项目中处理这个问题,这个问题目前是airbnb的一个公开问题。 为了解决这个问题,我对原始项目进行了分叉,以便它与jalali moment一起工作,从正确的日期开始的月份,到github和npm存储库的链接如下: 如何使用:

我正在尝试使用非英语语言环境(波斯语),一切都很好,除了一个月的第一天

月份不是从波斯语(Jalaali)日历的第一天开始到第30天,而是从每月的第10天开始,一直持续到下个月的第10天


这个问题甚至存在于他们的生活中。我想知道是否有办法解决这个问题。

我一直在一个项目中处理这个问题,这个问题目前是airbnb的一个公开问题。 为了解决这个问题,我对原始项目进行了分叉,以便它与jalali moment一起工作,从正确的日期开始的月份,到github和npm存储库的链接如下:

如何使用:

  • 从“moment jalaali”导入moment Jalali

  • 在要使用datepicker的组件的构造函数中,设置适当的区域设置:

    momentJalali.locale('fa')

  • 从分叉存储库导入日期选择器:

从“react dates jalali”导入{SingleDatePicker,DateRangePicker}

  • 在“渲染”部分中,按以下方式使用singdatepicker:

    <SingleDatePicker
          date={date} //momentDate if you have not set this property,it automatically sets to today
          focused={this.onFocusChange}//function change focused:open-close
          onFocusChange={.../function}
          showClearDate={true}
          required={true}
          isRTL={true}
          monthFormat={monthFormat}//for persian:'jMMMM jYYYY', for english :'MMMM YYYY'
          onDateChange={this.onDateChange}//function set your date Change
     />
    
     <DateRangePicker
      startDate={startDate} //moment startDate if you have not set this property,it automatically sets to today
      endDate={endDate} //moment endDate
      onFocusChange={.../function}
      required={true}
      isRTL={true}
      onDatesChange={this.onDatesChange}//function set startDate and endDate
    focusedInput={focusedInput}//similar to airbnb api-open\close
    showClearDates={true}
      monthFormat={monthFormat}//for persian:'jMMMM jYYYY', for english :'MMMM YYYY'
       />
    
    
    
  • 在“渲染”部分中,按以下方式使用daterangepicker:

    <SingleDatePicker
          date={date} //momentDate if you have not set this property,it automatically sets to today
          focused={this.onFocusChange}//function change focused:open-close
          onFocusChange={.../function}
          showClearDate={true}
          required={true}
          isRTL={true}
          monthFormat={monthFormat}//for persian:'jMMMM jYYYY', for english :'MMMM YYYY'
          onDateChange={this.onDateChange}//function set your date Change
     />
    
     <DateRangePicker
      startDate={startDate} //moment startDate if you have not set this property,it automatically sets to today
      endDate={endDate} //moment endDate
      onFocusChange={.../function}
      required={true}
      isRTL={true}
      onDatesChange={this.onDatesChange}//function set startDate and endDate
    focusedInput={focusedInput}//similar to airbnb api-open\close
    showClearDates={true}
      monthFormat={monthFormat}//for persian:'jMMMM jYYYY', for english :'MMMM YYYY'
       />
    
    
    
不用说,此存储库支持此处未提及的所有其他airbnb API


如果您的站点是多语言的,您也可以使用此存储库,并且您可以随时更改区域设置和月份格式。

我刚刚导入了momentlocale,如下所示:

import moment from 'moment';
import 'moment/locale/pt-br';

有一个关于此版本的定义必须应用于主库。此库未使用最新版本的react dates,因此不应用其调试。此外,这说明jalali在onDatesChange处理程序中有错误,它在选择时返回错误的日期,并且没有关于它的文档。好的,我知道了,我正在尝试在新版本的Airbnb中修复它