pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

  • <tfoot id='ON0SI'></tfoot>
    1. <legend id='ON0SI'><style id='ON0SI'><dir id='ON0SI'><q id='ON0SI'></q></dir></style></legend>
      <i id='ON0SI'><tr id='ON0SI'><dt id='ON0SI'><q id='ON0SI'><span id='ON0SI'><b id='ON0SI'><form id='ON0SI'><ins id='ON0SI'></ins><ul id='ON0SI'></ul><sub id='ON0SI'></sub></form><legend id='ON0SI'></legend><bdo id='ON0SI'><pre id='ON0SI'><center id='ON0SI'></center></pre></bdo></b><th id='ON0SI'></th></span></q></dt></tr></i><div class="7b7tnt7" id='ON0SI'><tfoot id='ON0SI'></tfoot><dl id='ON0SI'><fieldset id='ON0SI'></fieldset></dl></div>

        <small id='ON0SI'></small><noframes id='ON0SI'>

        • <bdo id='ON0SI'></bdo><ul id='ON0SI'></ul>

        將 gregorian 日期轉換為 angular 2 和 Ionic 2 中的波斯

        Convert gregorian date to persian(jalali) date in angular 2 and Ionic 2(將 gregorian 日期轉換為 angular 2 和 Ionic 2 中的波斯(jalali)日期)
          <tbody id='ZHnwH'></tbody>
        • <bdo id='ZHnwH'></bdo><ul id='ZHnwH'></ul>

            <tfoot id='ZHnwH'></tfoot>
                <legend id='ZHnwH'><style id='ZHnwH'><dir id='ZHnwH'><q id='ZHnwH'></q></dir></style></legend>
              1. <small id='ZHnwH'></small><noframes id='ZHnwH'>

                <i id='ZHnwH'><tr id='ZHnwH'><dt id='ZHnwH'><q id='ZHnwH'><span id='ZHnwH'><b id='ZHnwH'><form id='ZHnwH'><ins id='ZHnwH'></ins><ul id='ZHnwH'></ul><sub id='ZHnwH'></sub></form><legend id='ZHnwH'></legend><bdo id='ZHnwH'><pre id='ZHnwH'><center id='ZHnwH'></center></pre></bdo></b><th id='ZHnwH'></th></span></q></dt></tr></i><div class="hpxvhtb" id='ZHnwH'><tfoot id='ZHnwH'></tfoot><dl id='ZHnwH'><fieldset id='ZHnwH'></fieldset></dl></div>

                  本文介紹了將 gregorian 日期轉換為 angular 2 和 Ionic 2 中的波斯(jalali)日期的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我熟悉位于 npm 中的一個包,用于將公歷日期轉換為波斯語 (jalali),但我不知道應該如何在 ionic 2 angular 2 項目中使用它.

                  I'm familiar with one package located in npm for converting gregorian date to persian (jalali), but i don't know how should i use it in ionic 2 angular 2 projects.

                  Jalali-date

                  或角度 1 的這個包:

                  or this package for angular 1:

                  ADM-dateTimePicker

                  是否可以將此包轉換為 angular 2?任何的想法?歡迎或教程...

                  is it possible to convert this package to angular 2? any idea? or tutorial are welcome...

                  推薦答案

                  好的,我為此寫了轉換器,

                  ok, i wrote convertor for this purpose,

                  首先在你的項目中添加一個提供者:

                  first add a provider in your project:

                  import {Injectable} from '@angular/core';
                  @Injectable()
                  export class PersianCalendarService {
                    weekDayNames: string[] = ["????", "??????", "??????",
                      "?? ????", "????????",
                      "??? ????", "????"];
                    monthNames: string[] = [
                      "???????",
                      "????????",
                      "?????",
                      "???",
                      "?????",
                      "??????",
                      "???",
                      "????",
                      "???",
                      "??",
                      "????",
                      "?????"];
                    strWeekDay: string = null;
                    strMonth: string = null;
                    day: number = null;
                    month: number = null;
                    year: number = null;
                    ld: number = null;
                    farsiDate: string = null;
                  
                    today: Date = new Date();
                  
                    gregorianYear = null;
                    gregorianMonth = null;
                    gregorianDate = null;
                    WeekDay = null;
                    buf1: number[] = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
                    buf2: number[] = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335];
                  
                    constructor() {
                    }
                    PersianCalendar(gregorianDate): string {
                      this.today = gregorianDate;
                      this.gregorianYear = this.today.getFullYear();
                      this.gregorianMonth = this.today.getMonth() + 1;
                      this.gregorianDate = this.today.getDate();
                      this.WeekDay = this.today.getDay();
                      this.toPersian(gregorianDate);
                      return this.strWeekDay + " " + this.day + " " + this.strMonth + " " + this.year;
                  
                  
                    }
                    toPersian(gregorianDate) {
                      if ((this.gregorianYear % 4) != 0)
                        this.farsiDate = this.func1();
                      else
                        this.farsiDate = this.func2();
                      this.strMonth = this.monthNames[Math.floor(this.month - 1)];
                      this.strWeekDay = this.weekDayNames[this.WeekDay + 1];
                  
                    }
                  
                  
                    func1(): string {
                      this.day = this.buf1[this.gregorianMonth - 1] + this.gregorianDate;
                      if (this.day > 79) {
                        this.day = this.day - 79;
                        if (this.day <= 186) {
                          var day2 = this.day;
                          this.month = (day2 / 31) + 1;
                          this.day = (day2 % 31);
                          if (day2 % 31 == 0) {
                            this.month--;
                            this.day = 31;
                          }
                          this.year = this.gregorianYear - 621;
                        }
                        else {
                          var day2 = this.day - 186;
                          this.month = (day2 / 30) + 7;
                          this.day = (day2 % 30);
                          if (day2 % 30 == 0) {
                            this.month = (day2 / 30) + 6;
                            this.day = 30;
                          }
                          this.year = this.gregorianYear - 621;
                        }
                      }
                      else {
                        this.ld = this.gregorianYear > 1996 && this.gregorianYear % 4 == 1 ? 11 : 10;
                        var day2 = this.day + this.ld;
                        this.month = (day2 / 30) + 10;
                        this.day = (day2 % 30);
                        if (day2 % 30 == 0) {
                          this.month--;
                          this.day = 30;
                        }
                        this.year = this.gregorianYear - 622;
                      }
                      var fullDate = this.day + "/" + Math.floor(this.month) + "/" + this.year;
                      return fullDate
                    }
                  
                  
                  
                    func2(): string {
                      //console.log("entered func2");
                      this.day = this.buf2[this.gregorianMonth - 1] + this.gregorianDate;
                      this.ld = this.gregorianYear >= 1996 ? 79 : 80;
                      if (this.day > this.ld) {
                        this.day = this.day - this.ld;
                        if (this.day <= 186) {
                          var day2 = this.day;
                          this.month = (day2 / 31) + 1;
                          this.day = (day2 % 31);
                          if (day2 % 31 == 0) {
                            this.month--;
                            this.day = 31;
                          }
                          this.year = this.gregorianYear - 621;
                        } else {
                          var day2 = this.day - 186;
                          this.month = (day2 / 30) + 7;
                          this.day = (day2 % 30);
                          if (day2 % 30 == 0) {
                            this.month--;
                            this.day = 30;
                          }
                          this.year = this.gregorianYear - 621;
                        }
                        var fullDate = this.day + "/" + Math.floor(this.month) + "/" + this.year;
                        return fullDate
                      }
                      else {
                        var day2 = this.day + 10;
                        this.month = (day2 / 30) + 10;
                        this.day = (day2 % 30);
                        if (day2 % 30 == 0) {
                          this.month--;
                          this.day = 30;
                        }
                        this.year = this.gregorianYear - 622;
                      }
                    }
                  }
                  

                  下一步:在您的代碼中導入此服務:

                  the next step: import this service in your code:

                  import {PersianCalendarService} from '../../providers/persian-calendar-service/persian-calendar-service';
                  

                  下一步:在 @Page 部分實現提供者的名稱

                  the next step: implement the provider's name in @Page section

                  @Page({
                    templateUrl: 'build/pages/getting-started/getting-started.html',
                    providers: [PersianCalendarService]
                  })
                  

                  構造函數

                  constructor(
                     public persianCalendarService: PersianCalendarService) {}
                  

                  那么您只需將日期傳遞給函數以獲得良好的 Jalali 日期輸出:

                  then just you need to pass the date to the function for getting a nice output of Jalali date:

                   getJalaliDate(date) {
                  var date1 = this.persianCalendarService.PersianCalendar(date);
                  this.farsiDate = date1;
                  

                  }

                  我會盡快將這段代碼添加到 github 中.謝謝

                  i'll add this code in github soon. Thanks

                  這篇關于將 gregorian 日期轉換為 angular 2 和 Ionic 2 中的波斯(jalali)日期的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Use IScroll in Angular 2 / Typescript(在 Angular 2/Typescript 中使用 IScroll)
                  anime.js not working in Ionic 3 project(Anime.js 在 Ionic 3 項目中不起作用)
                  Ionic 3 - Update Observable with Asynchronous Data(Ionic 3 - 使用異步數據更新 Observable)
                  Angular 2: file not found on local .json file(Angular 2:在本地 .json 文件中找不到文件)
                  In Ionic 2, how do I create a custom directive that uses Ionic components?(在 Ionic 2 中,如何創建使用 Ionic 組件的自定義指令?)
                  Use ViewChild for dynamic elements - Angular 2 amp; ionic 2(將 ViewChild 用于動態元素 - Angular 2 amp;離子2)

                    <bdo id='GeRQk'></bdo><ul id='GeRQk'></ul>
                      <tbody id='GeRQk'></tbody>
                  • <i id='GeRQk'><tr id='GeRQk'><dt id='GeRQk'><q id='GeRQk'><span id='GeRQk'><b id='GeRQk'><form id='GeRQk'><ins id='GeRQk'></ins><ul id='GeRQk'></ul><sub id='GeRQk'></sub></form><legend id='GeRQk'></legend><bdo id='GeRQk'><pre id='GeRQk'><center id='GeRQk'></center></pre></bdo></b><th id='GeRQk'></th></span></q></dt></tr></i><div class="hnnzhfx" id='GeRQk'><tfoot id='GeRQk'></tfoot><dl id='GeRQk'><fieldset id='GeRQk'></fieldset></dl></div>
                  • <tfoot id='GeRQk'></tfoot>

                        • <small id='GeRQk'></small><noframes id='GeRQk'>

                            <legend id='GeRQk'><style id='GeRQk'><dir id='GeRQk'><q id='GeRQk'></q></dir></style></legend>
                            主站蜘蛛池模板: 纯化水设备-纯水设备-超纯水设备-[大鹏水处理]纯水设备一站式服务商-东莞市大鹏水处理科技有限公司 | 云南成人高考_云南成考网| 冲击式破碎机-冲击式制砂机-移动碎石机厂家_青州市富康机械有限公司 | 急救箱-应急箱-急救包厂家-北京红立方医疗设备有限公司 | 衬四氟_衬氟储罐_四氟储罐-无锡市氟瑞特防腐科技有限公司 | 无锡网站建设_企业网站定制-网站制作公司-阿凡达网络 | 考勤系统_考勤管理系统_网络考勤软件_政企|集团|工厂复杂考勤工时统计排班管理系统_天时考勤 | 电动葫芦-河北悍象起重机械有限公司| 杭州营业执照代办-公司变更价格-许可证办理流程_杭州福道财务管理咨询有限公司 | 礼仪庆典公司,礼仪策划公司,庆典公司,演出公司,演艺公司,年会酒会,生日寿宴,动工仪式,开工仪式,奠基典礼,商务会议,竣工落成,乔迁揭牌,签约启动-东莞市开门红文化传媒有限公司 | 涡街流量计_LUGB智能管道式高温防爆蒸汽温压补偿计量表-江苏凯铭仪表有限公司 | 烟气在线监测系统_烟气在线监测仪_扬尘检测仪_空气质量监测站「山东风途物联网」 | 预制直埋蒸汽保温管-直埋管道-聚氨酯发泡保温管厂家 - 唐山市吉祥保温工贸有限公司 | 脉冲布袋除尘器_除尘布袋-泊头市净化除尘设备生产厂家 | 空气净化器租赁,空气净化器出租,全国直租_奥司汀净化器租赁 | 气动隔膜泵-电动隔膜泵-循环热水泵-液下排污/螺杆/管道/化工泵「厂家」浙江绿邦 | RO反渗透设备_厂家_价格_河南郑州江宇环保科技有限公司 | 辐射色度计-字符亮度测试-反射式膜厚仪-苏州瑞格谱光电科技有限公司 | 东莞动力锂电池保护板_BMS智能软件保护板_锂电池主动均衡保护板-东莞市倡芯电子科技有限公司 | 河南卓美创业科技有限公司-河南卓美防雷公司-防雷接地-防雷工程-重庆避雷针-避雷器-防雷检测-避雷带-避雷针-避雷塔、机房防雷、古建筑防雷等-山西防雷公司 | 低气压试验箱_高低温低气压试验箱_低气压实验箱 |林频试验设备品牌 | 全温恒温摇床-水浴气浴恒温摇床-光照恒温培养摇床-常州金坛精达仪器制造有限公司 | 私人别墅家庭影院系统_家庭影院音响_家庭影院装修设计公司-邦牛影音 | HV全空气系统_杭州暖通公司—杭州斯培尔冷暖设备有限公司 | 全自动烧卖机厂家_饺子机_烧麦机价格_小笼汤包机_宁波江北阜欣食品机械有限公司 | 万师讲师网-优质讲师培训师供应商,讲师认证,找讲师来万师 | 玖容气动液压设备有限公司-气液增压缸_压力机_增压机_铆接机_增压器 | 事迹材料_个人事迹名人励志故事 学生作文网_中小学生作文大全与写作指导 | 利浦顿蒸汽发生器厂家-电蒸汽发生器/燃气蒸汽发生器_湖北利浦顿热能科技有限公司官网 | 定时排水阀/排气阀-仪表三通旋塞阀-直角式脉冲电磁阀-永嘉良科阀门有限公司 | 国资灵活用工平台_全国灵活用工平台前十名-灵活用工结算小帮手 | 卷筒电缆-拖链电缆-特种柔性扁平电缆定制厂家「上海缆胜」 | 宿舍管理系统_智慧园区系统_房屋/房产管理系统_公寓管理系统 | 低压载波电能表-单相导轨式电能表-华邦电力科技股份有限公司-智能物联网综合管理平台 | 棉柔巾代加工_洗脸巾oem_一次性毛巾_浴巾生产厂家-杭州禾壹卫品科技有限公司 | 苏商学院官网 - 江苏地区唯一一家企业家自办的前瞻型、实操型商学院 | 东莞市海宝机械有限公司-不锈钢分选机-硅胶橡胶-生活垃圾-涡电流-静电-金属-矿石分选机 | 广州中央空调回收,二手中央空调回收,旧空调回收,制冷设备回收,冷气机组回收公司-广州益夫制冷设备回收公司 | 百方网-百方电气网,电工电气行业专业的B2B电子商务平台 | 滑板场地施工_极限运动场地设计_滑板公园建造_盐城天人极限运动场地建设有限公司 | 礼仪庆典公司,礼仪策划公司,庆典公司,演出公司,演艺公司,年会酒会,生日寿宴,动工仪式,开工仪式,奠基典礼,商务会议,竣工落成,乔迁揭牌,签约启动-东莞市开门红文化传媒有限公司 |