SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Nov 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    UNIX timestamp and other calendars

    hi, i try to translate charts of highcharts.com to Jalali Calendar. highchart use unixtime stamp for point and tick position . but when i convert dates to jalali i have a big problem.
    current year in jalali is 1391 and current year in Gregorian is 2012 . by default high chart using time stamp so :
    Code:
    var date = new Date() - new Date(1970,01,01,0,0,0,0);
    or
    Code:
    var date = new Date();
    date.getTime();
    and the result is 42 year diffrent between unix timestamp and Gregorian . but in jalali the problem come :
    1391 - 1970 = -579 and highchart get error.
    how can i fix problem of unixtime stamp and other calandars ?
    can i write getTime Method that work with jalali date of 1970 ? (1348,10,11) ?
    sorry for my bad english language.

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Sorry, but JavaScript only uses gregorian for its dates. You would need to convert from Jalila to Gregorian, and use the the Gregorian dates throughout JavaScript.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Member
    Join Date
    Nov 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you right , at first i convert to jalali with this . i i only convert date and day and month everything ok but when i convert year to jalali everything go wrong.i need when selection navigation thick yaer in http://www.highcharts.com/stock/demo/area it show me first month of jalali not first month of Gregorian . so i need to convert years .

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by MBe View Post
    you right , at first i convert to jalali with this . i i only convert date and day and month everything ok but when i convert year to jalali everything go wrong.i need when selection navigation thick yaer in http://www.highcharts.com/stock/demo/area it show me first month of jalali not first month of Gregorian . so i need to convert years .
    Which implies that all you need is to apply a Facade pattern, so that the internal Gregorian dates can be retrieved for display on the page as Jalali dates, and are converted from the displayed Jalali dates to Gregorian dates for the script to use.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •