Dátumformátum + dátumformátum-típus exportálása

The spam filter installed on this site is currently unavailable. Per site policy, we are unable to accept new submissions until that problem is resolved. Please try resubmitting the form in a couple of minutes.
Kategória: 
Leírás

Features és a saját dátumformátumok/típusok összakalapálása már több éves issue. Nálam szinte minden projectnél előjön, a #drupal.hu irc csatornán is felmerül rendszeresen.

A feladat tehát a következő: Legyen egy kódbázisban tárolt, újrafelhasználható, tetszőleges dátumformátum-típus, amely egy dátumformátumhoz van rendelve.

No de mi ez a dátumformátum, és dátumformátum-típus?

Dátumformátum-típus: A php date függvényének a paramétere. Maga a string, amely a date() függvény kimenetét produálja, pl: M d, Y - G:i

Dátumformátum: Ez már a drupal saját vuduja. Egy típusnak három paramétere lehet:

  • type - A típus elnevezése
  • format - A dátumformátum stringje
  • locale - A nyelvek tömbje, amelyre a dátumformátumok alkalmazhatók, ha nincs megadva, akkor nyelvfüggetlen a beállítás.

Ahhoz, hogy nekünk kód alapú dátumformátumunk legyen, két hookkal kell dolgozni:

Dátumformátum
[geshifilter-drupal6] function MYMODULE_hook_date_formats() { return array( array( 'type' => 'M_d_yyyy_G_i', #ez csak a gépi név, lehet bármi, én így szeretem, hogy a kulcs némileg követi az eredményt. 'format' => 'M d, Y - G:i', 'locales' => array(), #nincs nyelvi korlátozás ), ) }[/geshifilter-drupal6]

Dátumformátum-típus

Itt fontos, hogy a kulcs megegyezzen a hook_date_formats() 'type' paraméterével. Az érték az admin/config/regional/date-time oldalon fog megjelenni, valahogy így:

[geshifilter-drupal6]function MYMODULE_hook_date_format_types() { return array( 'M_d_yyyy_G_i' => t('Example: Feb 5, 2013 - 14:09 (M d, Y - G:i)'), ); }[/geshifilter-drupal6]

Ezzel még viszont nincs vége. Ami a kettőt összekapcsolja, az egy változó, mégpedig a date_format_[type], tehát esetünkben a date_format_M_d_yyyy_G_i. Ha az adott typehoz egyetlen formatot vettünk fel, akkor csak az admin/config/regional/date-time oldalon kell nyomni egy save-t.
Ha ez kész van, mehet feature-be a változó.

Hozzászólások

You are so awesome! I do not

You are so awesome! I do not believe I've read through
a single thing like this before. So great to find somebody with a few original thoughts
on this subject. Really.. thank you for starting this up.

This web site is something that's needed on the web,
someone with some originality!

320mm Shock

Hi there, i read your blog

Hi there, i read your blog from time to time and i own a similar one and i
was just wondering if you get a lot of spam remarks?

If so how do you prevent it, any plugin or anything you can recommend?
I get so much lately it's driving me mad so any support is very much appreciated.

Just want to say your article

Just want to say your article is as amazing. The
clearness in your post is just nice and i could assume you're an expert
on this subject. Well with your permission allow me to
grab your RSS feed to keep updated with forthcoming post.
Thanks a million and please continue the rewarding work.

It's remarkable to pay a

It's remarkable to pay a visit this website and reading the views of all colleagues
about this paragraph, while I am also keen of getting know-how.

Great delivery. Sound

Great delivery. Sound arguments. Keep up the good work.|

60s Sunglasses

Hey there, I think your

Hey there, I think your website might be having browser compatibility issues.

When I look at your website in Firefox, it looks fine but when opening in Internet Explorer, it has some overlapping.
I just wanted to give you a quick heads up! Other then that, terrific blog!

Oh my goodness! Awesome

Oh my goodness! Awesome article dude! Thank you, However I am having difficulties with your RSS. I don't know the reason why I can't subscribe to it. Is there anybody having identical RSS issues? Anyone that knows the answer will you kindly respond? Thanx!!|

Just wish to say your article

Just wish to say your article is as amazing. The clarity in your post is simply excellent and i could assume you are an expert on this subject. Well with your permission let me to grab your RSS feed to keep updated with forthcoming post. Thanks a million and please carry on the gratifying work.|

Thanks a bunch for sharing

Thanks a bunch for sharing this with all of us you really realize what you are talking approximately!
Bookmarked. Kindly also visit my web site =). We can have a hyperlink exchange
arrangement among us

I visited various web sites

I visited various web sites except the audio feature for audio songs current at this website is genuinely excellent.|

Excellent goods from you,

Excellent goods from you, man. I've understand your stuff previous to and you're just too magnificent. I actually like what you have acquired here, really like what you are saying and the way in which you say it. You make it entertaining and you still care for to keep it smart. I can't wait to read far more from you. This is really a tremendous web site.|

Nice post. I was checking

Nice post. I was checking continuously this blog and I'm impressed! Extremely helpful info specifically the last part :) I care for such info much. I was looking for this particular info for a very long time. Thank you and good luck.|

Heya this is somewhat of off

Heya this is somewhat of off topic but I was wanting to know if blogs use WYSIWYG editors or if you have to manually code with HTML. I'm starting a blog soon but have no coding knowledge so I wanted to get advice from someone with experience. Any help would be greatly appreciated!|

Very nice post. I just

Very nice post. I just stumbled upon your blog and wished to say that I've truly enjoyed browsing your blog posts. After all I'll be subscribing to your feed and I hope you write again soon!|

I'm amazed, I must say.

I'm amazed, I must say. Seldom do I come across a blog that's both equally educative and amusing, and let me tell you, you have hit the nail on the head. The problem is an issue that too few folks are speaking intelligently about. I'm very happy that I came across this during my hunt for something relating to this.|

Hi exceptional website! Does

Hi exceptional website! Does running a blog similar to
this require a large amount of work? I have virtually no
expertise in programming but I was hoping to start my own blog soon. Anyways, should you have any recommendations or techniques for new blog owners please share.
I understand this is off topic however I simply needed to ask.
Thanks a lot!

Have you ever thought about

Have you ever thought about adding a little bit more than just
your articles? I mean, what you say is important and everything.
But imagine if you added some great photos or video clips to
give your posts more, "pop"! Your content is excellent
but with pics and videos, this site could
definitely be one of the best in its field. Good blog!

Hey there, You've performed

Hey there, You've performed an incredible job. I'll certainly digg it and personally suggest to my friends. I'm confident they'll be benefited from this web site.|

Hi there! This post couldn't

Hi there! This post couldn't be written any better! Reading through this post reminds me of my good old room mate!
He always kept talking about this. I will forward this
write-up to him. Pretty sure he will have a good read.
Thank you for sharing!

Great article! We are linking

Great article! We are linking to this particularly great post on our site. Keep up the great writing.|

Today, I went to the beach

Today, I went to the beach with my kids. I found a sea shell and gave it to my 4 year old daughter and said "You can hear the ocean if you put this to your ear." She placed the shell to her ear and screamed. There was a hermit crab inside and it pinched her ear. She never wants to go back! LoL I know this is totally off topic but I had to tell someone!|

These are genuinely wonderful

These are genuinely wonderful ideas in regarding blogging.
You have touched some pleasant things here. Any way keep up wrinting.

It's impressive that you are

It's impressive that you are getting ideas from this paragraph as well as from our dialogue made here.|

Hey! Do you know if they make

Hey! Do you know if they make any plugins to protect against hackers? I'm kinda paranoid about losing everything I've worked hard on. Any tips?|

Why people still make use of

Why people still make use of to read news papers when in this technological globe all is accessible on web?|

Link exchange is nothing else

Link exchange is nothing else except it is only placing the other person's weblog link on your page at suitable place and other person will also do same in favor of you.|

Amazing! This blog looks just

Amazing! This blog looks just like my old one! It's on a completely different subject but it has pretty much the same layout and design. Excellent choice of colors!|

I need to to thank you for

I need to to thank you for this wonderful read!! I absolutely enjoyed every little bit of it. I have got you book-marked to look at new stuff you post…|

Hello there! I could have

Hello there! I could have sworn I've been to this blog before but after browsing through some of the posts I realized it's new to me. Nonetheless, I'm definitely happy I discovered it and I'll be bookmarking it and checking back frequently!|

Hello! I know this is

Hello! I know this is somewhat off topic but I was wondering which blog platform are you using for this website? I'm getting tired of Wordpress because I've had problems with hackers and I'm looking at alternatives for another platform. I would be great if you could point me in the direction of a good platform.|

Today, while I was at work,

Today, while I was at work, my sister stole my iPad and tested to see if it can survive a forty foot drop, just so she can be a youtube sensation. My apple ipad is now broken and she has 83 views. I know this is completely off topic but I had to share it with someone!|

What's up to all, the

What's up to all, the contents existing at this website are in fact amazing for people knowledge, well, keep up the nice work fellows.|

Heya i am for the first time

Heya i am for the first time here. I came across this board and I find It really useful &
it helped me out a lot. I hope to provide one thing again and help others such as you aided me.

Hmm is anyone else having

Hmm is anyone else having problems with the images on this blog loading?
I'm trying to find out if its a problem on my end or
if it's the blog. Any feed-back would be greatly appreciated.

My partner and I absolutely

My partner and I absolutely love your blog and find nearly all of your post's to be just what I'm looking for. Would you offer guest writers to write content to suit your needs? I wouldn't mind composing a post or elaborating on many of the subjects you write regarding here. Again, awesome blog!|

I like the valuable info you

I like the valuable info you provide in your articles. I'll bookmark your blog and check again here regularly. I am quite certain I will learn a lot of new stuff right here! Good luck for the next!|

Hi there everyone, it's my

Hi there everyone, it's my first pay a quick visit at this website, and article is genuinely fruitful in favor of me, keep up posting these articles.|

I got this web page from my

I got this web page from my buddy who shared with me regarding this website and at the moment this time I am browsing this web site and reading very informative posts at this place.|

We're a bunch of volunteers

We're a bunch of volunteers and opening a new scheme in our community. Your web site provided us with helpful information to work on. You've performed a formidable job and our entire neighborhood shall be thankful to you.|

My coder is trying to

My coder is trying to persuade me to move to .net from
PHP. I have always disliked the idea because
of the costs. But he's tryiong none the less.

I've been using WordPress on a variety of websites for about a year and am anxious about switching
to another platform. I have heard fantastic things about blogengine.net.
Is there a way I can import all my wordpress content into it?

Any help would be really appreciated!

Brass Y Strainer

I have read so many articles

I have read so many articles or reviews about the blogger lovers but this piece of writing is genuinely a nice post, keep it up.|

Hi I am so grateful I found

Hi I am so grateful I found your web site, I really found you by error, while I was looking on Google for something else, Nonetheless I am here now and would just like to say cheers for a tremendous post and a all round thrilling blog (I also love the theme/design), I don't have time to look over it all at the moment but I have saved it and also included your RSS feeds, so when I have time I will be back to read a great deal more, Please do keep up the great work.|

Having read this I thought it

Having read this I thought it was really enlightening. I appreciate you spending some time and effort to put this informative article together. I once again find myself personally spending a lot of time both reading and posting comments. But so what, it was still worthwhile!|

Hozzászólás

A mező tartalma nem nyilvános.
  • Internal paths in double quotes, written as "internal:node/99", for example, are replaced with the appropriate absolute URL or relative path.
  • Engedélyezett HTML elemek: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <del> <img>
  • A webcímek és email címek automatikusan linkekké alakulnak.
  • A sorokat és bekezdéseket a rendszer automatikusan felismeri.
  • Engedélyezett HTML elemek: <a> <blockquote> <br> <cite> <code> <dd> <del> <div> <dl> <dt> <em> <li> <ol> <p> <span> <strong> <ul>
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <bash>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <mysql>, <php>, <python>, <ruby>, <sql>. The supported tag styles are: <foo>, [foo].
  • Minden email cím át lesz alakítva ember által olvasható módon, vagy (ha a JavaScript engedélyezett) ki lesz cserélve kattintható, de biztonságos hivatkozásra.