Skip to content
Advertisements

How to get time zone offset in javascript?

Here is the function:   function getTimeZoneOffset() { var currentDate = new Date(); var date1 = new Date(currentDate.getFullYear(), 0, 1, 0, 0, 0, 0); var temp = date1.toGMTString(); var date3 = new Date(temp.substring(0, temp.lastIndexOf(” “))); var hoursDiffStdTime = ((date1 – date3) / (1000 * 60 * 60)) * 60; return hoursDiffStdTime; } And if you want to get the offset with daylight saving then look at the below function:   function getTimeZoneOffsetDayLightSaving() { var currentDate = new Date(); var date2 = new Date(currentDate.getFullYear(), 6, 1, 0, 0, 0, 0); var temp = date2.toGMTString(); var date4 = new Date(temp.substring(0, temp.lastIndexOf(” “))); var hoursDiffDaylightTime = ((date2 – date4) / (1000 * 60 * 60)) * 60; return hoursDiffDaylightTime; }

Read More →

XPath Operators

Here are the operators we use in xslt for various calculations I have symbolized the numbers by e1, e2,.. Operator Description e1 + e2 If e1 and e2 are numbers, their sum e1 – e2 e1 minus e2 e1 * e2 Product of e1 and e2 e1 div e2 If e1 and e2 are numbers, their quotient as a fl oating-point value. e1 mod e2 The fl oating-point remainder of e1 divided by e2 . e1 = e2 Tests to see if e1 equals e2 e1 & lt ; e2 Tests to see if e1 is less than e2 . You can’t say e1 < e2 inside an attribute: the less-than sign must be escaped as “& lt; ” . e1 & lt ;= e2 Tests to see if e1 is less than or equal to e2 e1 & gt ; e2 Tests for greater-than e1 != e2 Tests for inequality e1 and e2 True if both e1 and e2 are true. If e1 is false, e2 is not evaluated e1 or e2 True if either e1 or e2 is true. If e1 is true, e2 is not evaluated e1 / e2 The / operator separates levels in a tree. For example, “/barge/load” selects all children of the element child of the document node //e Abbreviation for descendant-or-self:: e ./e Abbreviation for self:: e ../e Abbreviation for parent:: e @e Abbreviation for attribute:: e e1 | e2 Selects the union […]

Read More →

XPath String Functions

Below are some of the common string functions used in XSLT 1) format-number() – Converts a number into a string 2) starts-with(string1, string2) – Returns true if the first string starts with the second string. 3) contains(string1, string2) – Returns true if the first string contains the second string. 4) normalize-space(string) – Trims the leading and trailing space from string. Also replaces consecutive occurrences of white space with a single space. 5) translate(string1, string2, string3) – Returns string1 after any matching characters in string2 have been replaced by the characters in string3. 6) concat(string1, string2, …) – Concatenates all strings (i.e. joins them together). Some more functions — 7) current() – Returns the current node 8) document() – Used to access the nodes in an external XML document 9) element-available() – Tests whether the element specified is supported by the XSLT processor 10) function-available() – Tests whether the function specified is supported by the XSLT processor 11) generate-id() – Returns a string value that uniquely identifies a specified node 12) key() – Returns a node-set using the index specified by an element

Read More →