ComputersProgramming

A matter of time: how to do date format and where to search the date essence

Time never stops. In the context of programming, it has a beginning, content and end. As soon as the work begins, the program is started, the script is turned on, the site is opened ... At first the time in programming became "data", that is "nothing", but after many years from the beginning it regained its legal status.

Computer business started with a timer (any processor works on a timer): without clear time signals, neither digital, nor analogue, nor natural - simply does not exist. Time always and in everything is present, but on how it is represented and taken into account, the quality of the program depends, and, what is very important at times, how long it will exist.

The philosophy of time, which is essential

In different periods, different languages perceived the time factor differently and had a certain date format. But if we do not take the real-time systems of the past, then understanding in the proper sense (in the mass, first of all) came just recently.

At first, the real reality was poorly reflected in programming. The developers sought to accomplish the task, but did not always realize the importance of time.

будет иметь катастрофическое значение. Surprisingly, even in the minds of no one was: many developers and program users did not even think at the end of the last century that the problem of the number of digits in the designation of the year in the date format would be catastrophic.

Only when 2000 approached, everyone suddenly thought about that the formal framework is tight, and not only for what the programmer came up with for himself, developing his own algorithm.

When the passions by the number of figures in the year died down, a new idea arose: localization. It turned out that the date is very dependent on the place of its application, and the concept of date format has finally passed from simple views to the category of structured data.

Cosmic problems and mathematical calculations

The undoubted success of Fortran, the language to which the original bias toward large calculations is attributed, has brought to life only one consequence. The computer was not fast enough to decompose the trapezoid curves by calculating the differentials and integrals. Not everyone understands the deep meaning of higher mathematics, but the time that a computer spends on processing a different formula is noticed by everyone.

The processing of time data in large volumes or over long distances acquires a significant time factor: the error may well be equal to the cost of a spacecraft that has flown off in the wrong direction, just because a particular engine has not switched on at the right time.

Date format JavaScript (browser language)

Perhaps the Internet has become a reason for the growth of interest in time as a continuous and significant given, it is not so important. All modern programming languages have, as a temporary element, an object or structure equipped with a proper structure and own semantics.

In particular, in the language of the JavaScript browser, date format looks like a Date object:

Here, the function padl () simply supplements the number to two digits. Under the text it is clear what the date is in JavaScript language - everything is very simple, it is indicated accurately and conveniently in use.

Java date format (Sun concept)

A different attitude to the date in the Java language. Date format is represented here not by one abstract class. However, the abundance of his methods deserves a separate article. Formatting is rendered in a separate object, which allows for the operation of the date format to take into account the locale, that is, to issue the date in the language in which it is needed.

The developer can use classes: DateFormatSymbols, Calendar, GregorianCalendar, TimeZone, MaskFormatter and others. The view of date format is much more extensive than in other languages. Each class has its own purpose.

It does not matter whose merit in the globalization is date format. Financial opportunities and high technology of Sun, predetermining a serious attitude to the concept of time, or global information ideas and powerful Oracle databases. But the Java language has transformed the simple concept of date format into a system of diverse objects and globalized its implementation.

Calendar on jQuery

An excellent, simple and affordable implementation date is undoubtedly the datapicker. Using the jQuery engine, it has become surprisingly easy to use, allows you to quickly insert on any page the ability to select the exact time or time interval and present the result in string format date.

'#dateField' ).datepicker() календарик, у которого можно изменить не только внешний вид соответственно тематике страницы, но и локализовать под нужный язык. The input tag, receiving input focus, displays a calendar with the help of the $ ( '#dateField' ) .datepicker () method , which can change not only the appearance corresponding to the topic of the page, but also localize to the desired language. You can set not only the date, but also the time, and the days of the week.

Initially, the datapicker appeared for the input field, but can be used on another element - div or span, for example. The result can be not only placed in the input field in the form of a formatted string (you can easily change the content of the terms), but also used as a variable.

Datapicker is certainly not a representation of date format from Oracle / Java, but the features of this widget will satisfy the most refined tastes. The developer does not need to write his own version of the date and algorithms for working with it - he gets not only a handy calendar, but also a dialogue (a set of functionalities for traffic by days, weeks, months. You can record the start date of the period and the end date.

Even if the site requires its own version of the time presentation, it's reasonable to apply datepicker at the initial stage of development.

Similar articles

 

 

 

 

Trending Now

 

 

 

 

Newest

Copyright © 2018 en.unansea.com. Theme powered by WordPress.