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.
Category: 
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ó.

Comments

I always spent my half an

I always spent my half an hour to read this blog's content every day along with a
cup of coffee.

I don't know if it's just me

I don't know if it's just me or if everyone else experiencing issues with your blog.
It appears like some of the written text on your content are running
off the screen. Can someone else please provide feedback
and let me know if this is happening to them too? This could be a issue with my browser because I've had this happen before.
Thank you

It's a shame you don't have a

It's a shame you don't have a donate button! I'd most certainly donate
to this superb blog! I guess for now i'll settle for book-marking and adding your RSS feed to my Google account.
I look forward to fresh updates and will share this blog with my Facebook group.

Chat soon!

Simply wish to say your

Simply wish to say your article is as amazing.

The clearness to your put up is simply cool and i can assume you're an expert in this subject.

Fine along with your permission let me to snatch your RSS
feed to stay updated with drawing close post. Thanks a million and
please keep up the rewarding work.

Excellent weblog right here!

Excellent weblog right here! Additionally your website quite a bit up fast! What host are you using? Can I am getting your affiliate hyperlink on your host? I desire my web site loaded up as fast as yours lol|

Hi there I am so thrilled I

Hi there I am so thrilled I found your webpage, I really found you by mistake,
while I was browsing on Askjeeve for something else, Nonetheless I am here
now and would just like to say thanks a lot for
a tremendous post and a all round interesting blog (I also love the theme/design), I
don’t have time to read it all at the moment but I have book-marked
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 awesome jo.

It's remarkable to go to see

It's remarkable to go to see this web page
and reading the views of all colleagues concerning this post, while
I am also zealous of getting knowledge.

My brother suggested I may

My brother suggested I may like this website.
He was entirely right. This put up actually made my day. You can not consider
simply how much time I had spent for this information! Thank you!

Inspiring quest there. What

Inspiring quest there. What happened after? Take care!

Do you have a spam issue on

Do you have a spam issue on this site; I also am a blogger,
and I was wondering your situation; many of us
have developed some nice procedures and we are looking to swap methods with other folks, please shoot me an e-mail if interested.

I love your blog.. very nice

I love your blog.. very nice colors & theme.

Did you design this website yourself or did you hire
someone to do it for you? Plz respond as I'm looking to construct my own blog and would like to
know where u got this from. thanks a lot

Thanks in support of sharing

Thanks in support of sharing such a nice idea, paragraph is pleasant,
thats why i have read it completely

Hi there! I could have sworn

Hi there! I could have sworn I've visited this blog before but after browsing through many of the posts I realized it's new to me. Anyhow, I'm definitely happy I discovered it and I'll be book-marking it and checking back often!|

What's up it's me, I am also

What's up it's me, I am also visiting this website daily, this web site is
truly pleasant and the visitors are actually sharing nice thoughts.

I know this if off topic but

I know this if off topic but I'm looking into starting my own weblog and was curious what all
is required to get set up? I'm assuming having a
blog like yours would cost a pretty penny? I'm not very internet smart so I'm not 100% sure.
Any tips or advice would be greatly appreciated.

Appreciate it

Thank you for every other

Thank you for every other great article. The place else
may just anybody get that kind of info in such a perfect
means of writing? I have a presentation subsequent
week, and I am on the search for such info.

Great information. Lucky me I

Great information. Lucky me I discovered your site by chance (stumbleupon).

I have book-marked it for later!

Howdy! Quick question that's

Howdy! Quick question that's totally off topic. Do you know how to make your site mobile friendly?
My weblog looks weird when viewing from my iphone.
I'm trying to find a template or plugin that might be able to fix this problem.
If you have any suggestions, please share. Cheers!

It's amazing in favor of me

It's amazing in favor of me to have a website, which is good in support of
my knowledge. thanks admin

I am regular visitor, how are

I am regular visitor, how are you everybody? This paragraph posted at this
web site is truly fastidious.

Actually no matter if someone

Actually no matter if someone doesn't know afterward its up to other visitors that they
will assist, so here it takes place.

Greetings! Very helpful

Greetings! Very helpful advice within this article! It is the little changes that will make the largest changes.
Many thanks for sharing!

Wow, this article is

Wow, this article is fastidious, my younger sister
is analyzing such things, so I am going to tell her.

Link exchange is nothing else

Link exchange is nothing else however it is simply placing the other person's blog link on your page at proper place and
other person will also do same in favor of you.

Thanks for your personal

Thanks for your personal marvelous posting!
I seriously enjoyed reading it, you might be a great author.I
will ensure that I bookmark your blog and may
come back someday. I want to encourage you to ultimately
continue your great job, have a nice evening!

Very shortly this website

Very shortly this website will be famous among all blogging viewers, due to it's pleasant posts

You could certainly see your

You could certainly see your expertise within the work you write.
The sector hopes for even more passionate writers like you
who are not afraid to say how they believe.
All the time follow your heart.

You're so awesome! I don't

You're so awesome! I don't suppose I've read through a single thing like this before.
So good to discover someone with original thoughts on this topic.
Seriously.. thank you for starting this up. This web site
is something that's needed on the internet, someone with some originality!

Because the admin of this web

Because the admin of this web site is working, no hesitation very
shortly it will be famous, due to its quality contents.

Great post. I was checking

Great post. I was checking constantly this weblog and I am impressed!
Very useful info particularly the final phase :) I care for such info a lot.
I used to be seeking this certain info for a very lengthy time.
Thanks and best of luck.

I do believe all the ideas

I do believe all the ideas you've introduced for your post. They're really convincing and will certainly work. Nonetheless, the posts are too quick for starters. May you please extend them a little from subsequent time? Thanks for the post.|

Great article, just what I

Great article, just what I was looking for.

I all the time emailed this

I all the time emailed this blog post page to all my contacts, for the reason that if like to read it next my contacts will too.

Hi! This post could not be

Hi! This post could not be written any better!
Reading through this post reminds me of my old room mate!
He always kept talking about this. I will forward this page to
him. Fairly certain he will have a good read.
Thank you for sharing!

Oh my goodness! Incredible

Oh my goodness! Incredible article dude! Thanks, However I am encountering difficulties with your RSS.
I don't know why I cannot subscribe to it. Is there anybody else
having identical RSS problems? Anyone who knows the solution will you kindly respond?
Thanks!!

I was recommended this web

I was recommended this web site by my cousin. I'm not sure whether this post is written by him as no one else know such detailed about my trouble.
You're wonderful! Thanks!

Valuable information. Lucky

Valuable information. Lucky me I discovered your web site unintentionally, and I'm shocked
why this accident didn't came about earlier! I bookmarked it.

I quite like looking through

I quite like looking through a post that will make people think.
Also, thank you for allowing for me to comment!

It is appropriate time to

It is appropriate time to make some plans for the future and it is time to be happy. I have read this post and if I could I desire to suggest you some interesting things or tips. Perhaps you could write next articles referring to this article. I wish to read even more things about it!|

I'm really impressed with

I'm really impressed with your writing skills and also with the layout on your blog.
Is this a paid theme or did you customize it yourself?
Either way keep up the nice quality writing, it's rare to see a nice blog like this one these days.

It's appropriate time to make

It's appropriate time to make some plans for the longer term and it is time to be happy.
I have read this publish and if I may just I want to counsel you some
fascinating issues or advice. Perhaps you can write subsequent articles relating
to this article. I want to learn more issues approximately it!

It's enormous that you are

It's enormous that you are getting thoughts from this piece of writing
as well as from our discussion made here.

Hi, I do believe this is a

Hi, I do believe this is a great site. I stumbledupon it ;
) I will return yet again since i have saved as a favorite it.
Money and freedom is the best way to change, may
you be rich and continue to help other people.

Excellent blog here! Also

Excellent blog here! Also your site so much up fast! What host are you the usage of?
Can I am getting your affiliate link on your host?
I want my web site loaded up as quickly as yours lol

Simply want to say your

Simply want to say your article is as astounding.

The clearness to your put up is simply spectacular and that i can assume you're a
professional in this subject. Well with your permission let me to
clutch your feed to keep updated with drawing close post.
Thanks one million and please carry on the rewarding work.

I was able to find good

I was able to find good advice from your content.

Hello, always i used to check

Hello, always i used to check webpage posts here
early in the daylight, for the reason that i love to learn more and more.

Its like you read my mind!

Its like you read my mind! You appear to know a lot about
this, like you wrote the book in it or something. I think that you could do with a few pics to drive the message home a bit,
but other than that, this is magnificent blog. A fantastic read.

I'll certainly be back.

For latest information you

For latest information you have to pay a quick visit world wide web and on the web I found this web site as a best site
for latest updates.

Thanks very nice blog!

Thanks very nice blog!

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Internal paths in double quotes, written as "internal:node/99", for example, are replaced with the appropriate absolute URL or relative path.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <del> <img>
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • Allowed HTML tags: <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].
  • Each email address will be obfuscated in a human readable fashion or (if JavaScript is enabled) replaced with a spamproof clickable link.