#setdate
Explore tagged Tumblr posts
Text
Don't mind making out tho. Cuz that's just kissing, doesn't inherently mean anything else foekdisjs
Aahhh I should stop-
2 notes
·
View notes
Text
I actually hate drawing rooms or anything like that...but I feel like chiharu and osomatsu take baths together often as a sorta sweet lil activity and I'm determined to give chiharu a cute bathroom.....SETDATE ME
6 notes
·
View notes
Text
Everything You Need to Know About JavaScript Date Add Day

When Working With Dates in JavaScript, adding days to a date is a common yet essential task. JavaScript provides a straightforward way to achieve this by manipulating the Date object using methods like setDate and getDate.
By creating a function to add days, you can easily calculate future or past dates. For more complex date operations or handling various edge cases, consider using date libraries like Moment.js or date-fns.
For a comprehensive guide and additional resources on JavaScript date manipulation, including adding days, TpointTech offers valuable tutorials and examples to help you master this crucial aspect of programming.
Understanding JavaScript Date Objects
In JavaScript, the Date object is used to work with dates and times. You can create a Date object using the Date constructor, which can take different formats such as a string, a number representing milliseconds since January 1, 1970, or individual date and time components.
let today = new Date();
console.log(today); // Outputs the current date and time
To add days to a date, you'll need to manipulate this Date object.
Adding Days to a Date
JavaScript doesn’t have a built-in method to directly add days to a date, but you can achieve this by using the following approach:
Get the Current Date: Start by obtaining the current date using the Date object.
Add Days: To add days, you can manipulate the date by modifying the day of the month.
Here’s a step-by-step method to add days to a Date object:
function addDays(date, days) {
let result = new Date(date); // Create a copy of the date
result.setDate(result.getDate() + days); // Add the specified number of days
return result;
}
let today = new Date();
let futureDate = addDays(today, 5);
console.log(futureDate); // Outputs the date 5 days from today
In this code, the addDays function takes two parameters: the original date and the number of days to add. It creates a new Date object based on the original date and modifies it by adding the specified number of days using the setDate method. The getDate method retrieves the current day of the month, and by adding days to it, the date is updated.
Handling Edge Cases
When adding days, be mindful of edge cases, such as month and year boundaries. The Date object automatically handles transitions between months and years. For example, adding days to a date at the end of one month will correctly roll over to the next month.
let date = new Date('2024-08-30');
let newDate = addDays(date, 5);
console.log(newDate); // Outputs 2024-09-04
In this example, adding 5 days to August 30 results in September 4, demonstrating how JavaScript correctly manages month transitions.
Working with Time Zones
JavaScript dates are sensitive to time zones. The Date object represents dates in the local time zone of the system where the script is running. To avoid issues with time zones, especially when working with applications across different regions, you may need to convert between time zones or use libraries designed for handling time zones.
Using Libraries for Advanced Date Operations
For more complex date manipulations, including adding days, consider using a date library like Moment.js or date-fns. These libraries provide additional functionality and simplify date arithmetic:
Using Moment.js:
let moment = require('moment');
let today = moment();
let futureDate = today.add(5, 'days');
console.log(futureDate.format('YYYY-MM-DD'));
Using date-fns:
let { addDays } = require('date-fns');
let today = new Date();
let futureDate = addDays(today, 5);
console.log(futureDate.toISOString().split('T')[0]);
These libraries offer a more intuitive API for date manipulation and can be particularly useful in large projects.
Conclusion
Mastering the art of Adding Days to a Date in JavaScript is essential for effective data management in your applications. By using the Date object and its methods, you can easily manipulate dates to meet your needs, whether you're scheduling events or calculating deadlines.
For more complex date operations, leveraging libraries like Moment.js or date-fns can provide added convenience and functionality.
To further enhance your JavaScript skills and explore advanced date handling techniques, TpointTech offers comprehensive tutorials and resources. Embracing these tools and practices will ensure your date manipulations are accurate and efficient.
0 notes
Text
Working with Dates in JavaScript
This topic explores the Date object in JavaScript, a powerful tool for creating, manipulating, and formatting dates and times. The Date object allows you to handle a wide range of date and time operations, from getting the current date to parsing, formatting, and calculating dates. This topic covers the creation of Date objects, common methods and properties such as getDate(), setDate(), toLocaleDateString(), and getTime(). Practical examples demonstrate how to perform tasks like date arithmetic, formatting dates for display, and working with time zones. Mastering the Date object enables you to handle date and time functionality effectively in your JavaScript applications.
0 notes
Text
Build a Age Calculator in React framework
The provided code snippet is an example of an age calculator implemented in the React framework. It utilizes functional components and hooks to calculate and display the age based on the user's input. Here's a breakdown of the code:
Index.js FIle import React, { useState } from 'react' const Age = () => { const [birthDate, setBirthDate] = useState(""); const [date, setDate] = useState(null) const [month, setMonth] = useState(null) const [year, setYear] = useState(null) const calculateAge = (birthDate) => { if (!birthDate) return; const currentDate = new Date(); if (new Date(birthDate) > currentDate)…
View On WordPress
0 notes
Text
JavaScript Date And Time. Here's Everything You Need To Know
JavaScript Date And Time. Here's Everything You Need To Know #javascript #javascripttutorial #javascriptdateandtime #jsdateandtime #programmingbeginner #webdevbeginner #webdevtutorial #learnwebdevelopment #learnweb #learnjavascript #learnjs #code
Last time we talked about JavaScript timers. And now you will learn how to work with JavaScript Date And Time. As you may know, Date object is built-in JavaScript Object. Basically what it does, it allows you to get the user’s local time by accessing the systems clock through browser. This method also provides several methods for managing, manipulating and formatting date and time. How To…
View On WordPress
#coding#dateandtime#javascript#javascriptdev#jsdateandtime#setdate#settime#tutorial#web#webdev#webdevelopment#website#webtutorial
0 notes
Text
Had like a full on conversation with my cute prosecutor and as always he was like “if there’s anything I can do to make things better let me know, the other guys are quick but me not so much” and I just said “no no I think you’re fine” and he just went “oh....well thank you” omggggg why does he do this why does he pause like that and sound like he’s taking that to heart don’t do this guy I’m gonna fall
7 notes
·
View notes
Text
Javascript setdate last day of month

#Javascript setdate last day of month update#
#Javascript setdate last day of month code#
* -įunction setDateFieldValue(arrOfFieldInternalNames)else if($(this).find("div").
#Javascript setdate last day of month code#
The code for the file “DateFieldValueOnClick.js” looks like this: /* Set datepicker value to "first day of month", "today" or "last day if month" The variable “arrOfFields” is an array of the FieldInternalNames of all the date picker-fields you want to add this feature to. Array of fields to add this function to If adding days shifts the month or year, the changes are handled automatically by the Date object. If you want midnight of last day of the previous month, then: var d new Date() d.setDate(0) d.setHours(0,0,0,0) console.log(d) If you want to know the last day of the previous month, based on provided year/month: var year 2016, month 11 var d new Date(year, (month - 1)) d.setDate(0) d.setHours(0,0,0,0) console. const d new Date () d.setDate(d.getDate() + 50) Try it Yourself. The code for the file “DateFieldValueOnClick.js” is found below.Īdd a CEWP below – it is essential that it is placed below – your list-form as briefly described here, and add this code: If you want to know the last day of the previous month, based on provided year/month: var year 2016, month 11 var d new Date (year, (month - 1)) d.setDate (0) d.setHours (0,0,0,0) console.log (d) var str d.getFullYear () + '-' + (d.getMonth () + 1) + '-' + d.getDate () console. The setDate () method can also be used to add days to a date: Example. Previous: Write a JavaScript function to get the month start date. Contribute your code and comments through Disqus.
#Javascript setdate last day of month update#
If you download another version, be sure to update the script reference in the sourcecode. See the Pen JavaScript - Get the month end date-date-ex-53 by w3resource (w3resource) on CodePen. The pictures and the sourcecode refers to jquery-1.3.2.min. In this example i have made a document library with a relative URL of “/test/English/Javascript” (a sub site named “test” with a sub site named “English” with a document library named “Javascript”): Here’s a solution for setting either “first day of month”, “today” or “last day of month” by clicking on a link above the date picker, or by pressing “F”, “T” or “L” in the date picker field itself.Ĭreate a document library to hold your scripts (or a folder on the root created in SharePoint Designer). Is it possible to add a clickable “button” or icon next to a date picker that would insert “Today’s Date” into the field box? I also updated the function init_fields in the example. Updated the code example to fix some quotes that was formatted wrong due to migrating from my old server a long time ago.

0 notes
Text
Inktobertale (3)
Something more setdate for yesterday. I'm sorry I didn't post here, I was tired, and I forgot. It was all I could do to finish the prompt. Anyway, october is also whumptober, right? So... ======
Ink didn't know where he was exactly. Just an empty, long forgotten AU with access to a void in the multiverse. He was sitting on the edge now, nearly blank. Apathy ran through his bones like marrow through any other skeleton's. He was holding two of his vials in his hands. A dark turquoise and navy blue. Each vial swirled, and both had an aura of sadness. Ink had never been quite sure what they were for, and oftentimes he forgot to take them. Sadness and regret.
Ink hated overdosing one of those two. Maybe even more than anger. He had wondered why he hadn't done what he came here to do a long time ago. He wanted so badly to drop those vials into the endless void. He didn't know what was stopping him. Nothing really, but his own self. He could just drop them into the void and be done with it. But... Shouldn't he consider the risks of doing so?
Surely sadness and pain and regret had uses, or there would not be them. Monster and human evolution was alike in that aspect. Nothing was useless, and if it was, it was left behind. So sadness must have a reason, right? Regret's was obvious. If it did not exist, then a being would keep doing the same harmful things over and over, without care for the consequences.
He slid the navy vial back into its place, and wrapped both of his hands around the dark turquoise vial. Ink should just-
"Ink?" A familiar voice, bringing warm into the emptiness of the cold void. Ink felt arms wrap around him from behind and drag him onto more stable ground. "Ink! We were worried, yanno? I don't want to scold you, that's more Blue's style anyway, but why are you here?"
Oh. Dream expected an answer.
"I... want to know... why sadness is..."
"I think I know why." Dream pulled him into a hug. "Without sadness there wouldn't be comfort. I know that, out of all emotions, sinking into sadness is the worst, but it has its uses. Please. You know that we'll always pull you out when you get too deep." Ink smiled. He really should to take his paints.
"I know. " Ink drank his paints. Even sadness. He knew why he needed it, now, maybe even more so than the other paints. Together, he and Dream left through a golden portal.
4 notes
·
View notes
Text
Arthropods and Awkwardness Chapter 3: Interesting Insects
The third and final chapter of this mini-series is here! This chapter is a lot longer and less smut-filled than I anticipated at first, I’ll admit, but I’m pretty proud of it. Thank you so much for reading, and enjoy!
read on ao3
Words: 7.8k
Description: Dan and Phil finally get their shit together...right?
Warnings: mentions of spiders, angst, mentions of previous toxic relationship (nothing too graphic), swearing
It had been a long, quiet two weeks since the incident with Dan’s attractive neighbor. Overall, he wasn’t surprised that he hadn’t heard from the older man, but he was arguably still disappointed. He really did like Phil, beyond just the fact that he was really hot. Phil was interesting and had depth and an amazing sense of humor. If only Dan hadn’t managed to fuck it up.
Dan’s grumbling to himself about his lost chance as he steps out of his bathroom in only a towel, barely paying attention to anything other than the fact that it was hot. Really hot, for London, especially when he didn’t have any air con. “Fuckin’ old London buildings,” he mutters, pulling a pair of blue boxers up his legs, leaving the damp towel on the floor. He wasn’t expecting company, so he didn’t really care how messy his room was. And right now, it was arguably quite a mess. Clothes littered the floor, clean and unclean alike, and Dan wasn’t very keen on picking them up.
Tugging on a thin t-shirt and nothing more, Dan collapses on his bed, turning to gaze out his window. It really was rather hot, so he had opened it earlier that morning, in the hopes that it would provide a little bit of air circulation, at the very least. It didn’t really appear to be actually accomplishing anything, but the noise drifting up from the street made him feel a little less alone, which was certainly a plus.
Sighing, Dan reaches for his phone that was laid charging on his pillow, but as he does his eyes dart up to his headboard, and he freezes. Suddenly, all the blood has drained out of his face, and possibly his body, because sat on the wall just above the headboard is a spider about the size of his hand.
Well, actually that was probably an over-exaggeration, as it was likely closer to the size of his thumbnail, but Dan was nothing if not overdramatic, so he scrambled away from his bed, falling onto his ass in the process. Not letting his eyes drift from the hell-beast on the wall, he stands slowly, backing out of his room as carefully as he can, as to not startle it.
“Okay,” he breathes to himself. This was fine. Everything was fine. Sure, he was literally stuck in a room with his biggest fear, but it was fine. He could just grab a cup and a piece of paper and do exactly what Phil had- oh! Phil!
Dan turns to walk to the front door with determination before realizing that Phil would likely not be interested in helping him, given how their last conversation had went. Dan was certain he could still feel the taste of Phil on his lips, but he had tried desperately to not think about it in the days following the incident. Sadly, the intrusion of the insect on his wall was making it all come flooding back.
With a deep sigh and his skin already crawling, Dan goes to his kitchen and picks up a plastic cup from his sink, and then grabs a notebook from his coffee table on the way back to his bedroom. You can do this, he chants to himself as he approaches his bed slowly. It’s just a little spider. You can handle it.
He’s not entirely sure that his mantra is working, but he climbs onto his bed slowly, holding the cup in his left hand and tentatively gripping the notebook in his left. “Hi there, buddy. Erm- don’t try to kill me, but you can’t be here. I live here, and I don’t want you here. So, I’m gonna have to evict you.” He tells the spider, cringing when one little leg twitches. He squeaks, freezing for a moment. “Easy there, little buddy.” He breathes, slowly lifting the cup.
His muscles are incredibly tense and he’s sweating from nerves and the obnoxious London heat, but he slowly raises the cup, and with a precision he wasn’t aware he had, he quickly closed it over the spider, holding his breath as he did so. “Oh my god,” He gasps, looking through the clear glass at the little monster residing within it. “I caught it! I fucking caught it!” He calls to no one in particular.
Dan realizes the hard part is definitely not over yet, as he still has to manage to get the little bugger off the wall using the notebook. Swallowing hard, he pushes the very edge of the cover under the lid of the cup, shivering in disgust when the spider twitches. “Yes!” He shouts, sitting back on his heels, grinning at his success. “Fuck yeah. I knew I could do it. Fuck you, little spider. You can’t live here.” He taunts the insect, and he swears it hisses at him. “Ew,” he mumbles, shifting to move his feet out from under him.
And that’s when it all goes to shit.
His foot had somehow gotten tangled under his duvet, curtesy of early morning him being too lazy to make his bed, so when he goes to pull his legs out from under him, he loses his balance. His body jerking close to the edge, he throws a hand out to catch his fall, and can only watch in mute horror as the cup tumbles off the notebook, the spider going right along with it.
Only then, when he realizes the spider is out and probably full of vengeance, does Dan scream.
“Fuck!” He shouts as he scrambles fully off his bed, kicking the duvet away from him as he pushes himself off the floor. He’s shivering violently, just the thought of the spider being out causing his skin to crawl. Without checking to see where exactly the spider went, he decides he literally can’t handle this himself, and quickly makes his way to his front door.
Mad or not, he was about to go disrupt whatever nice day Phil was probably having and beg him, once more, to come rescue him from a fucking spider no bigger than his thumb. He’d rethink it if he wasn’t so objectively terrified of the little monsters, but he was literally petrified of them, so he was absolutely going to shove his pride aside and knock on his crush’s door.
Leaving the door to his flat wide open, Dan stomps across the hallway and doesn’t even think as he raises his fist and knocks on the white door in front of him. He knocks four times impatiently before stepping back, rocking on his heels uncertainly. It occurs to him only then that he’s only wearing boxers and a t-shirt, but just as he feels the embarrassment about that seeping in, the door swings open.
Naturally, since Dan feels, and looks, like he’s falling apart, Phil looks incredibly well put together and attractive. Dan swallows hard, allowing his eyes to drift from the black Jurassic Park t-shirt, down to his shorts that display his long legs, and back up to the blue eyes that are glasses-free. Phil seems to be appraising Dan as well, but he has a look of confusion on his face that probably rivals Dan’s look of awe.
“Dan? What’s going on?” Phil asks slowly.
"Well, this is going to sound really stupid," Dan takes a deep breath before settling back on his heels, biting his lip. "Hi, by the way," he adds, blushing when Phil rolls his eyes and crosses his arms. Dan would be lying if he said he wasn't staring straight at his biceps when he did this.
"What?" Phil demands, sounding no less thrilled to be seeing Dan than Dan himself was, given the circumstances.
"Er- there's, well, I thought I caught it, but then I fell, so..." Dan rambles. Phil raises an eyebrow, still obviously confused. "There's another spider. I... Can you, um..." He trails off uncertainly, suddenly pretty positive that Phil is going to tell him to fuck off. "Actually, nevermind, this was stupid, I'm sorry," Dan shakes his head quickly, spinning on his heel to return back to his own flat.
It was fine, he could just burn down the entire bedroom, it would all be fine. He'd blame it on faulty outlets or something. Maybe he'd claim it was just the excessive London heat. Yeah, that actually sounds relatively believable, all things considered. He could totally just blame it on that-
He feels his arm being tugged on gently, and turns with a frown to find Phil looking at him, a soft, pitying look on his face. "I'll come get the spider for you," He says gently, letting go of Dan's arm when he has his attention. Gesturing for Dan to lead the way, Phil waits patiently.
"Oh," Dan stutters out. "Oh- okay. Sure, come on." He shakes his head in confusion at the turn of events before slowly crossing over into his apartment and leading the way into his bedroom. "It might have... Well, I sort of tried to catch it and then dropped it on my bed, so I'm not entirely sure where it is now." Dan bites his lip in embarrassment as they come to stand in his flat.
Phil glances over at him once, his blue eyes flickering down to Dan's lips once. Dan releases his bottom lip from between his teeth, but blushes at the way that Phil's eyes slowly travel back up to meet his own. "Okay. I'll have a look around." He nods at Dan before walking over to the rumpled bed. He picks up the cup and notebook, setDating them on the bedside table before lifting up the duvet cautiously.
"Sorry, I know it's a mess," Dan feels the need to apologize with Phil standing in his messy bedroom, and his cheeks flood with heat when Phil only shrugs. He was twenty-seven, for fuck's sake, couldn't he keep his room clean? He vows to do better from now on, but his subconscious helpfully reminds him that this would probably be the last time Phil would even step foot in his flat, let alone his bedroom.
After a few minutes of Phil shaking out the duvet, he gingerly tosses it onto the bed, the glances around the floor carefully. He takes only a few moments, then sighs. "I don't know, Dan. I don't see it anywhere. Was it bigger than the last one?" He asks, running a hand through his quiff. Dan bites his lip, shaking his head slowly.
He holds his thumb out and then shrugs. "It was about the size of my thumbnail, give or take," He says quietly, trying his best not to sound like a child. After a short silence, he sighs. "I'm sorry I bothered you. Thank you for coming over to look. I... I won't bother you with things like this anymore." He promises softly.
Phil studies him for a few minutes before sighing, letting his eyes trail over to the open window. "You didn't... You didn't bother me, Dan." He says softly.
Dan tries not to let himself hope, but he can't help the way he perks up at Phil's words. "Really?" He asks, aware that he sounds like an excited child.
Sighing again, Phil shakes his head. "Of course not. I don't mind helping you out with your spider thing. Don't ever feel bad about coming to me for that." His words are sweet and generous, but Dan can't help but feel like it's sort of Phil's way of compensating for the fact that Dan is really just an overgrown child who can't handle things himself.
Without thinking too much about the consequences, he suddenly blurts out, "I'm sorry, Phil."
The older man shakes his head, but Dan doesn't think he knows what he's actually apologizing for. "No, Dan, you don't have to be sorry, it's fine, okay? I don't mind helping."
"No, not for that." Dan swallows hard. "Well, I guess partially for that. But no, really what I wanted to apologize for was being a massive twat the other day.” He lets his eyes drift to the floor, unsure if he’s actually ready to face the look on Phil’s face, which is probably disgust, or annoyance. “So, yeah. I’m sorry.”
There's a silence where neither of them say a word, but then he hears a short laugh. Surprised, Dan glances up at the ebony-haired man in front of him, who looks amused. "Really? That's the best you've got, Dan?" He deadpans, his amusement quickly shifting to a look of indifference.
Dan's heart plummets, and he tries not to let his panic show on his face. God, he was really hoping that this would go well. "Um..." He trails off slowly. "No, I guess not." He sighs, resigned.
Phil stares at him for a moment before shrugging, sitting on his bed as if it's his house. "Well, I'd like a better apology, given we went out for coffee and then you tried to jump my bones like two hours later." He crosses his arms, a look of unfiltered annoyance on his face.
Trying not to let his face show his surprise, Dan swallows hard. The words hurt, sure, but they weren't untrue, sadly. Nodding numbly, he goes to sit at the end of his bed, putting a fair amount of space between them. "I shouldn't have done that. I didn't realize you weren't on the same page as me, and when we came back here and started fooling around, I just assumed-" he catches the incredulous look on Phil's face and hurries to correct himself. "I'm not saying it was your fault! It wasn't, it was all on me, I just misunderstood. I... I guess I'm not really sure why I didn't realize it wasn't just about sex for you." He says uncertainly.
It's quiet for a moment before Phil speaks again. "Is that really all it was about to you?" He whispers, his voice sounding full of hurt.
Dan hurries to shake his head, reaching his hand out only to realize that Phil probably wouldn't appreciate the contact. "No! I had a great time getting coffee with you, and I think you're really fascinating. I didn't- god I didn't want to just fuck you and forget you. I just... I wasn't aware that you were looking for a relationship." Dan finishes, nearly inaudible.
Phil shakes his head at this. "So, what? If you didn't want to just screw and then kick me out, and you also didn't want a relationship, what did you want?" Phil is staring at Dan, but Dan finds it very hard to raise his eyes to meet the older man's, mainly due to his shame.
Shrugging, Dan pulls at a string on the end of his boxers. His face flushes when he realizes that he is still very underdressed, but he figures that it's ridiculous to be worried about it now. "I guess I just figured we could be... casual? I know, that's dumb. You already told me how you feel about that, and I respect that. I'm sorry I made you feel like your desires weren't respected when that happened, honest. That... that was never my intention." Ridiculously, Dan feels himself getting choked up, and he tries to subtly press his fingers to his eyes to stop the tears from welling up, but with Phil staring straight at him, he's sure it doesn't go unnoticed.
It occurs to Dan then, how ridiculous it is to be sitting there crying over a man he wasn't dating, and whom he had no real ties to. But there was just something so comforting and warm being in Phil's presence, and even though he was currently sat two feet away from him, Dan missed that comfort deeply.
"Thank you for apologizing." Phil says, suddenly going to stand. "I'm still a little pissed off, but it's nothing I can't handle." He glances around the room, his eyes not settling on Dan for once. "I'm sorry I couldn't find the spider. Maybe if you clean your room up you can find it, or maybe it's gone for now." His voice sounds tight, as if he's reciting lines that he's rehearsed, and Dan wonders if this seriously is going to end in the way he thinks, which is badly.
"Oh... Okay." Dan stands slowly, wringing his hands as he looks over at Phil. "Well... Um, thank you. For coming over here. And... and for letting me apologize. I..." he takes a deep breath before meeting Phil's gaze directly for the first time since he started apologizing. "I still want to be your friend, if you'll have me."
Phil studies him for a moment, several emotions flitting across his features; anger, pity, and maybe even hurt, before his eyes soften into something more closely resembling uncertainty. "We... I don't know if that's a good idea, Dan," He looks apologetic, but Dan feels that he's probably relieved to say the words.
"Oh," Dan feels as if his voice sounds very far away. "I guess... Um... Okay." He feels his shoulders sag as he gives in, tired of protesting.
"I'm not saying never," Phil supplies helpfully, a small smile on his face when Dan looks up at him. "I'm just saying... not right now, maybe. Okay? I think..." He trails off, glancing out Dan's window before his eyes slowly trail back to Dan's. "I think we both need a minute, okay? I don't doubt that I want you to be my friend, but I feel that on my part, at least, I need a little time to process what happened." He sounds hesitant, and while Dan's not entirely sure what he means, he nods.
"Okay," he whispers, glancing down at his feet. "I'm sorry."
He sees two feet come to a stop in front of his, and then feels a hand come up to the back of his head, followed by soft lips pressed to his hair. "I know," Phil murmurs back.
Dan squeezes his eyes shut, willing the tears away.
"Bye, Dan." Phil breathes into his hair. And then, he's gone, walking out of Dan's flat, and for the time-being, his life.
Dan tries not to let himself cry when he hears the door click shut quietly, but an hour later when he finally emerges from his bed with red rimmed eyes and a stuffy nose to get a glass of water- well, that's not really anyone else's business, is it?
---
It's a little over a month later, with lots of careful avoiding of his neighbor on Dan's behalf, that he hears a light rapping at his door. He wasn't expecting anyone, so he's confused as he steps out of the kitchen where he had been stress baking some cupcakes, wiping his flour covered hands on his jeans.
To say that he's surprised when he opens the door to find Phil standing in front of him would be an understatement. Looking sheepish but attractive as always, Phil stands with a small smile, holding an envelope in his hand. He's wearing black jeans similar to Dan's own, despite the warm weather, and he's paired it with a simple grey t-shirt.
"Hi," Phil says quietly, pushing his glasses further up the bridge of his nose, shifting on his feet awkwardly.
Dan pushes his curls back, cringing when he realizes they're damp with sweat from being in the kitchen for the last hour. "Hey," he breathes, trying hard not to fidget too much. He felt idiotic; it wasn't like they had dated or anything, yet he felt as if he was seeing his ex and his crush at the same time, his stomach a swarm of angry butterflies. "Um, come in," he offers, stepping away from the door and gesturing awkwardly for Phil to enter.
"Thanks," Phil smiles, a little awkwardly. He seems to smell the cupcakes, and his eyes light up. "Are you baking?" He asks, shock clear in his voice.
Dan nods, embarrassed. "Yeah, I do that every now and then." He makes his way to the kitchen, assuming that Phil would follow. "Um, not that you aren't welcome, of course, but... what are you doing here?" he asks, trying his hardest not to sound rude.
"Oh, um- here." Phil holds out the small envelope in his hand, and Dan looks at it in confusion before tentatively taking it. "Your mail ended up in my box again," he supplies, shrugging as he leans against the counter.
"Oh," Dan says, tearing open the envelope, which only has his name written on it, with no return address. There's a stamp, so it had to have been mailed, but he's incredibly curious as to what's in it. "Thanks for bringing it over, I-" He freezes when he pulls out the card inside. Suddenly, he forgets about Phil and whatever is happening between them, and his mind is thrust into a past that occurred almost two years ago now. A past with green eyes and wild curls that challenged his own, and hidden kisses in dark corners. A past with sneaking around and fights that lasted until early morning and slamming doors in dark apartments.
He vaguely hears Phil calling his name, but he's not paying attention. He fumbles with the wedding invitation in his hand, unaware that he's ripping it until it's fluttering to the ground in delicate little pieces.
"Dan!" Phil shouts, finally breaking through to him. "What the hell?"
Dan slowly turns to look at him, his head swimming with questions and thoughts, unsure if he should explain or demand that Phil leave so he could have a meltdown in private.
"Are you okay?" Phil asks, suddenly stepping closer to Dan and reaching a hand up to tuck a curl out of his face.
Shaking his head numbly, Dan stares down at the pieces of paper around his feet. "He's getting married," he whispers brokenly, his words barely heard.
"He... who, Dan? Who's getting married?" Phil sounds confused, and Dan wants to laugh. Who was exactly right, because the boy Dan had loved all those years ago would have never married. This has to be a joke. It has to be.
"Matthew." He whispers, as if the name would mean anything to Phil.
"I'm... I'm sorry, who? Dan, I don't know what you're talking about, but you're scaring me." Phil sounds almost panicked at this point, and Dan doesn't even flinch when the oven beeps, signaling that the cupcakes are done.
"You should go," Dan says, his voice and face void of emotion as he steps away from Phil, slipping an oven mitt on and taking the pan of cupcakes out of the oven, setting them on a cooling rack with the kind of ease that comes from doing something pretty regularly.
"Dan," Phil says firmly from behind him. Dan doesn't face him, but that doesn't stop Phil from grabbing his arm and tugging him around to face him.
Dan tears his arm out of Phil's grip, suddenly pissed that Phil would even pretend to care when he too somehow managed to break Dan's heart barely a month ago. "No," he snaps, glaring at the man in front of him. "I don't need you to sit here and act like you give a damn about me, okay? I can handle myself, so just," Dan gestures to the door carelessly. "Just go." He finishes quietly, his throat closing up. He desperately doesn't want to be alone right now, but he definitely doesn't want to be alone with someone who's only around out of pity.
Phil stares at him for a second before shaking his head. "No, fuck you, Dan. You don't get to decide that just because you don't care about me, that I feel the same about you. That's not your choice to make."
Tensing, Dan stares at him in surprise. "What?" He says slowly.
Rolling his eyes, Phil crosses his arms. "I know you've already moved on or whatever, and that's fine, but I do care about you, you know. As a friend, and... well, probably more, honestly, but I'm trying to respect that you don't want the same things. But you're clearly upset right now, and as a friend, I want to be here for you." Phil seems to deflate then, dropping his arms out of their defensive stance. "But, if you want to put up your walls and just keep me out of whatever is going on, that's fine. I get it."
He sounds incredibly resigned, and Dan can only stare in silence, completely floored by the honesty and pure kindness in Phil's words. The epiphany he has then was honestly one that's been a long time coming, but it suddenly occurs to him that maybe letting people in, or at least Phil, isn't such a bad thing. Sure, it was scary as hell, but... he could let Phil care about him as a friend, surely.
Phil seems to get tired of waiting, and he turns as if to leave. Dan swallows hard, realizing it's now or never. "Wait," he calls out, a little louder than he'd intended. Phil stops short at his voice, spinning to face him in surprise. Dan takes a deep breath before bending down to collect the pieces of the wedding invitation that he'd thrown in the floor.
"What are you doing?" Phil asks cautiously, taking an uncertain step towards Dan.
Dan sighs, moving the pieces around to piece the invitation back together, including the stupid picture of his ex's stupid face, as well as the name of him and his soon-to-be husband. Dan's hands shake as he pushes the pieces together to create a cohesive picture, and he lets out a breath as he slowly steps back. "C'mere." He murmurs, waving Phil closer to him.
Phil takes a hesitant step closer, glancing between the invitation to Dan. "What are you doing?" He repeats, sounding even more confused and concerned than before.
Dan shrugs. "I'm letting you in." He quirks his lip up just a little in a small smile.
Staring at Dan for a long moment, Phil finally turns his gaze to the invitation on the counter. He studies it for a moment before he glances back at Dan. He still looks confused, but he's got a calculating look on his face, as if he's slowly figuring out why this is important.
"Who's Matthew?' Phil asks softly.
Dan points to the green eyed face staring back at him from the gorgeously shot photo, a man Dan had only seen in online stalking sessions at four am accompanying his ex in the picture. Staring at the picture only makes Dan's heart ache, and he clears his throat, his eyes flicking instead over to the words.
A cutesy line about endless love is accompanied by the full names of both men, and Dan feels his heart race at the elegant script spelling out Matthew Thomas Langdon. If the name wasn't already engrained into his memory from spending almost four years with the man, it surely would be know from seeing it printed in the curly letters. Dan had never thought there'd be a day where he'd see it printed out like that, but if you had told him three years ago that when he did see it, it would be included with someone else's name, he would've laughed in your face.
He's not laughing now.
The kitchen is silent for a long time, but when the silence is broken, Dan is relieved. "I'm sorry," Phil says quietly. Dan can feel his gaze burning into the side of his face, but he doesn't respond other than a nod.
Taking a deep breath, Dan turns to pull himself up onto the counter beside the invitation, staring straight across the kitchen at the cupboards above his stove. "We dated for nearly four years," he begins slowly, trying his hardest to speak with a tone of indifference. Out of the corner of his eye, he sees Phil shift closer to him, his hand coming up to scoop the invitation up and depositing it in a heap at the other end of the counter.
"Dan," Phil murmurs. "You don't have to tell me about it if you're not ready to talk about it." He says gently, his voice full of understanding. This only serves to make Dan even more emotional, but he shakes his head.
"No." He decides then that he's tired of ruining the nice things in his life. If he's going to make it anywhere in the friendship he wants to build with Phil, then he needs to start by being honest with him, completely honest. "You wanted to know more about me as a person, right?" When Phil nods uncertainly, Dan smiles sadly. "Well, this is a good start."
"Do you want to go sit on your sofa while we talk? It's got to be more comfortable than your countertop." Phil suggests, nodding to the lounge.
Dan nods, hopping off the counter and going over to the kettle. "Tea?" He asks, uncertain what else he has to offer.
Phil smiles, which he takes to be a good sign. "I'd love some."
Nodding, Dan fills up the kettle with water, trying to ignore Phil's gaze following him around his kitchen. "Um, Hello Kitty, One Direction, or... um, Daddy? Mugs, I mean. You can pick." Dan blushes as he sets out his mug collection for Phil to pick from, embarrassed that those are the only ones he has clean.
Phil smirks as he looks over the cups before pointing to the Daddy mug. "But only because it looks like it can hold more tea," he comments, clearly still smirking, even as Dan flushes. "I don't have a daddy kink."
Dan coughs then, feeling suddenly very hot and overwhelmed. "Oh, well, that's- um- thanks for sharing... um... that...." Dan trails off awkwardly, suddenly very uncertain about what to say.
Snickering, Phil comes over to stand beside Dan, brushing his shoulder against Dan's. "I'm kidding, Dan. I'm just trying to lighten the mood." He has a genuine smile on his face, and Dan nods, trying his hardest not to feel completely embarrassed. "Sorry if I made you uncomfortable."
"No, um, it's fine." Dan struggles to come up with a joke, but all that leaves his mouth is, "I actually have kinks that are way worse than that one, so it's fine." As soon as the words leave his mouth, he covers his face. "Jesus- fuck, I'm sorry. I don't know what the hell is wrong with me. Forget I said that, that's cancelled," he rambles, shaking his head.
Phil only smiles, bringing his hand up to brush Dan’s curls back. “I don’t think you can say much to scare me off at this point,” he jokes, his tongue doing that thing where he pokes it out between his teeth. Knowing what that tongue feels like makes it very hard for Dan to focus on something other than the way it swipes across Phil’s bottom lip, but he forces himself to focus on making their tea.
“Well, I haven’t told you the full sob story about myself yet. We’ll see how you’re feeling after that, I guess,” he allows, handing Phil his cup a moment later.
Shrugging, Phil follows him into the lounge. “I guess you’ll just have to try me.”
Dan takes a deep breath as he and Phil settle onto the sofa, figuring it’s really just a matter of getting his thoughts together to explain the full story. Or, as much of it as he can stand to confess to someone who, although he feels very close to, is still very much a stranger.
“Matthew and I were together for nearly four years,” Dan begins, staring down at the coffee table. “We met when I started uni at Manchester, but I didn’t stick with it.” He swallows hard, glancing over at Phil when he sees that he’s perked up in interest.
“I’m from near Manchester, so it’s funny you went to uni there,” he supplies in explanation of his reaction.
Dan nods, smiling slightly as he files that fact away. “Explains the accent, then,” he teases lightly, nudging Phil’s knee with his own. His heart swells when Phil returns the nudge, a smile on his face as well.
“Hey, don’t bully me.” He pouts, sipping his tea to hide his smile.
Rolling his eyes, Dan nods in agreement before sitting back, gaze trailing over to his bookshelf. It’s stupid, he knows, but he still has a photo album of some of his best memories of himself and Matthew, although he swears that he only keeps it because there’s plenty of pictures of other people in it. (Three, actually. He’s counted.) He stands, giving Phil a reassuring smile as he steps over to the shelf to grab the small binder.
He hands it to Phil before he resumes his seat, watching the older man carefully as he opens the cover. Phil’s gaze softens notably when he takes in the first few pictures, which Dan knows without looking are of he and Matthew at nineteen and twenty-one, respectively. Part of Matt’s appeal to Dan was the fact that he was a junior when Dan was only a freshman in university, and Matthew just seemed so smart and interesting at the time. Really, Dan felt that he always paled in comparison to the older boy, even now, years after their breakup.
“You were such a twink,” Phil says from beside him, fondness and teasing in his voice. Dan elbows him sharply for that. “Hey!” He laughs in protest, rubbing his side.
“I was not!” Dan protests, although he’s vaguely aware that Phil is right. He’s honestly pretty sure that’s the whole reason Matthew ever gave him the time of day. The fact that he was kind of slutty and always around and flirting with Matthew probably helped.
Phil shrugs, as if to agree to disagree, before he flips to the next page. He studies these with a rapt curiosity and Dan feels strangely jealous. He knew that these pages included pictures of himself and Matthew the year before they started dating, when they were both just a mess of sexual tension and flirting. Matt had always been unfairly attractive, and Dan feels almost as if he’s just opened himself up for judgement as Phil is probably ogling over his hot ex-boyfriend and wondering how on earth Dan ever managed to snag him.
“You’re so beautiful, Dan,” Phil says softly, catching Dan completely off-guard. His finger traces over a picture on the bottom left, and Dan knows that it’s a picture of himself and Matthew on a couch, with his ex-boyfriend lounging casually behind a younger version of himself. While Matt looks noticeably drunk, Dan’s eyes are still bright without the effects of alcohol, his hair straight and long, which was just how he liked to keep it then.
“I looked like a twink, you were right,” Dan sighs, staring at the younger version of Matt with a frown on his face.
“No,” Phil protests, turning to face Dan with his eyebrows furrowed. “I’m serious, Dan. You… you were so cute, and yeah you looked like a power bottom even back then,” Dan chooses to ignore this, but he can’t help the flush on his cheeks. “But you…” Phil trails off as he turns back to the pictures. “You’re really something.”
You’re. As in, present tense. Dan’s heart swells with something like affection, but he struggles to stomp that down, as he knows it’s likely just to get him in trouble. Phil would surely not be such a fan of him after he heard the full story.
“Well, how about you look through these while I talk,” Dan suggests, nodding to the album in Phil’s hands.
Phil nods, mimicking a zipper across his lips and throwing away the key. Dan tries not to smile at this, but he can’t help it, it’s just too cute.
Dan settles in beside him, turning so that his knee is pressing against Phil’s hip, while his other leg hangs off the sofa. “We started dating when I was twenty-one and he was twenty-three.” Dan says quietly, watching as Phil flips through the pictures. “I had been in love with him since I met him pretty much, but he always found a way to… well, push me away.”
Phil glances up at this and raises an eyebrow but says nothing.
“First, it was school. He claimed that he didn’t want to prioritize anything above school. I told him that was fine, I didn’t need his constant love and affection. I… I thought I would be fine if he’d just let me be with him, you know? So, eventually, he gave in.” Dan swallows hard, trying not to lose his nerve. “We slept together on and off until I turned twenty, and by then I decided I wanted more. I told him I was in love with him.”
Dan goes quiet then, noticing the picture Phil has landed on. It was one that a friend had taken of them at a party before they started dating, but after the fight they had after Dan confessed his love. Matt hadn’t spoken to him for two weeks, but when this party came up, he asked Dan to go with him. Dan agreed, for some reason, and at some point, they wound up in the corner on the floor, talking and occasionally snogging. Luckily, this picture was just of the former, both of their heads bowed together, Dan’s hands moving about excitedly. He wonders absently what exact thought or idea younger-him had been explaining to the boy who probably couldn’t have given a fuck less.
“He told me he felt the same, but he didn’t think he was good enough for me. I begged him to give me a chance, and finally, he did.” Dan laughs bitterly then. “Biggest goddamn mistake I ever made.”
Phil frowns, turning to look at him. “Dan, you don’t owe me this explanation. If this is something… if this isn’t something you’re completely ready to talk about, we don’t have to. I- I can live with knowing that there’s things that you don’t want me to know.” Phil takes a deep breath then, and Dan tenses in anticipation for what he’s about to say. “I like you, a lot, for someone I barely know. And, it’s not ideal, but I can get over my aversion to the casual thing if that’s the only way you think you can… well, if it’s the only way you think you can be with me.” Phil finishes, biting his lip as he waits for Dan’s response.
Dan can only shake his head, fond and surprised. “No, Phil.” He shakes his head. “I don’t want you to just get over it. I… Dammit, I’ve really made a mess of things, and I know that, but I don’t want you to settle for that, because I’ve been there, and that’s shit. That’s what I’m trying to explain to you.” Dan gestures to the photo album. “My life revolved around someone who didn’t want me the same way I wanted him for years, and I can’t- no, I won’t do that to you.” Dan says firmly, shaking his head at the very idea of doing to Phil what Matthew had done to him.
“Oh,” Phil says slowly. He closes the photo album then, and Dan’s heart clenches. “Well, um. I- I guess I should go. I won’t- I don’t want to waste your time, Dan, and I get it, sometimes things like that aren’t mutual, and that’s-“ Phil’s rambling as he goes to stand, but Dan pulls on his arm to get him to sit back down.
Shaking his head adamantly, Dan laughs slightly at the confusion. “No, that’s not what I meant, Phil. I didn’t mean that I don’t want you,” Dan chuckles at this, looking away from the striking blue eyes with a blush. “Believe me, it’s the very opposite. I want you, really, really badly. And not just your cock, er- sorry, I’m crude sometimes-“ He apologizes, noticing the shock on Phil’s face, as well as the sudden color in the older man’s cheeks. “I want you, in the same way I wanted Matthew. Just… maybe to a healthier extent.”
“Oh.” Phil breathes, suddenly understanding just what the point of their conversation is.
“Listen, I really obsessed over Matthew and what our life was, but that didn’t go to plan, as you can tell.” He points to the photo album, but neither of them reaches for it. “He didn’t want to tell his parents, or anyone outside of our friend group, that we were together. His family didn’t know he was gay, and he had this deep, internalized shame about it.” Dan can’t help but feel sorry for Matthew, as he can’t imagine the kind of pain that must have been, hiding yourself like that for so long. Sure, Dan didn’t have a perfect family or even a perfect coming out story, but his family still loved him.
“I’m sorry.” Phil says softly, his hand coming over to rest on Dan’s.
Dan only nods. “It sucked, I’ll admit. But, according to my therapist, that really fucked with my head. Who knew, right? Spending six years of your life pining after someone who has so many internalized issues that they can’t love themselves, let alone you, can really fuck you up, apparently.” He tries his hardest to laugh, but at the very reminder he feels his eyes grow wet, and the laugh comes out sounding more like a sob.
“Dan,” Phil murmured. Before Dan could even think to protest, Phil was tugging on his leg, effectively pulling Dan to sit straddling his lap. Without pausing to check that Dan’s okay with this, because of course he is, Phil reaches up and tugs Dan’s head down gently to rest on his shoulder. “You are not fucked up, okay? Matthew was a fucking dick, and you deserve better than that twat.”
Dan sniffles into the soft fabric of Phil shirt as the older man strokes a hand down his back, while his other hand cards through Dan’s hair. “I… I really believed for a long time that it was me.” He whispers. He figures that at this point there’s very little point in putting on some pretense, so he allows himself this moment of weakness.
“Don’t,” Phil demands. “Don’t you ever think for a minute that it was your fault. Matthew was clearly an ass with daddy issues who never grew up, and if he decided to fuck it up with you, then that’s his loss. Dan, I barely know you, but I know you’re sweet and kind, you have an amazing sense of humor, and you are so compassionate.” Phil kisses his hair, and Dan feels his tears flowing freely.
“Thank you,” he mumbles wetly into Phil’s neck.
Phil’s quiet for a moment, petting Dan’s head. “Thank you for sharing all this with me.” He whispers suddenly.
Dan pulls away a little to make eye contact with him. “You’re welcome,” he whispers back, stopping barely two inches away from Phil’s face. “I wanted you to understand that it’s not you. I’m fucked up for reasons that have nothing to do with you, and those reasons don’t change how much I like you.”
“I think I understand a lot more about you now. I really appreciate you telling me about all of this. I… I hate to think that you went through all of that, but I’m so glad it didn’t work out between you two.” Phil blushes then, seemingly realizing how rude those words could be taken, if Dan was the type to misinterpret things. “I mean… You know what I mean. I’m just glad that he’s there, and you’re here. With me.” Phil’s eyes are soft and the light reflects off them in a way that makes the yellow and green flecks pop out.
“I am here. With you,” Dan repeats, nuzzling back into Phil’s neck. “Thank you for not running for the hills the minute I started freaking out and tearing up that invitation. That probably wasn’t my best moment.” Dan blushes at the memory.
Phil only chuckles beneath him, the movement of his chest reminding Dan of their somewhat compromising position. “It’s okay. I’ve seen stranger in my thirty-two years. I think I can handle just about anything you throw my way.” Phil teases gently.
“Yeah?” Dan says hesitantly, leaning back to get a look at Phil’s face to assess how far he’s allowed to go. It’s been a long day of confessions, and the last thing he wanted to do was take it too far.
Smiling softly, Phil nods. Then, he decides to spare Dan the worrying, and he brings a hand up to hold Dan’s jaw gently. “This okay?” He whispers just before their lips touch.
“Yes,” Dan breathes before closing the gap and pressing his lips to Phil’s. His eyes shut immediately, and he sighs against the soft lips, feeling as if he can finally breathe. Phil is slow and gentle, working against Dan’s lips with a tenderness that makes Dan all but melt. They stay like that for several moments, sharing slow, languid kisses.
When Phil finally pulls away, Dan is sad, but he’s also infinitely happier than he was before they kissed. “Does this mean I can have another chance?” He asks softly, staring down into blue eyes, drawing his bottom lip between his teeth as he waits for an answer.
Phil smiles up at him. “I think I’d like that.” He nods, craning his neck to capture Dan’s lips once more.
Dan smiles against his lips, his heart swelling in happiness. They still had a lot to discuss, and Dan would inevitably have to properly process the fact that his ex was tying the knot with someone who wasn’t him, but he felt that all of those things would be okay. Because now, at least he had Phil to sort through those things with him. He felt infinitely more in control knowing that he wouldn’t have to face any of it alone; the memories of his ex-boyfriend, the frightening realities of a new relationship, and yes, even the spiders which still invade his flat.
But, maybe this time he’ll go ahead and leave the window open. Sometimes it’s nice to let others in, and although he didn’t have to knock down all his walls at once, he could open a window, at the very least.
Then again, he’ll probably just leave his metaphorical window open, as an hour later when he’s gone in his room to fetch a blanket, he finds the spider from earlier and screams like a little girl, closing the window as Phil collects the demon-spawn.
So yeah, maybe the literal window can stay shut for now.
#phan#phanfiction#dan and phil#danandphil#spiders#angst#fluff#fanfiction#cupcakes that are never eaten
8 notes
·
View notes
Text
JavaScript Date 設置日子的方法

小知識教學類型: 網頁設計、網站製作
前��我們分別探討了JavaScript Date的簡介和JavaScript Date 獲取日子的方法,但Date Object 創建以後,我們應該如何設置日子,這尤關Date Object在網站程式中的相互聯繫,及同時影響著最後Date在用家的呈現樣式,今文我們一起了解有什麼JavaScript Date 設置日子的方法:
setDate() 將日期設置為數字 (1-31) e.g. const a = new Date(); a.setDate(10);
setFullYear() 設置年份(可選月份和日期) e.g. const a = new Date(); a.setFullYear(2022); 或 a.setFullYear(2022, 5, 5);
setHours() 設置小時 (0-23) e.g. const a = new Date(); a.setHours(32);
setMilliseconds() 設置毫秒 (0-999) setMinutes() 設置分鐘 (0-59) e.g. const a = new Date(); a.setMinutes(30);
setMonth() 設置月份 (0-11) e.g. const a = new Date(); a.setMonth(10);
setSeconds() 設置秒數 (0-59) e.g. const a = new Date(); a.setSeconds(30);
setTime() 設置時間(自 1970 年 1 月 1 日起的毫秒數)
而Date Object之間亦可作比較,例如使用大於或小於亦是常用的JavaScript Date Object相互比較的方法!
0 notes
Text
Logo Sql Çek-Senet Sorgusu
SELECT
convert(date,SETDATE,104)AS TARİH,
convert(date,DUEDATE,104) AS VADE,
(SELECT TOP (1) CL.DEFINITION_ FROM LG_001_05_CSTRANS AS CST INNER JOIN LG_001_CLCARD AS CL ON CST.CARDREF = CL.LOGICALREF WHERE (CST.CSREF = LGMAIN.LOGICALREF) ORDER BY CST.LOGICALREF) AS [CARİ ÜNVANI],
OWING AS BORÇLU,
CASE WHEN LGMAIN.CURRSTAT = 1 THEN 'Portföyde' WHEN LGMAIN.CURRSTAT = 2 THEN 'Ciro Edildi' WHEN LGMAIN.CURRSTAT = 3 THEN 'Teminata Verildi' WHEN LGMAIN.CURRSTAT = 4 THEN 'Tahsile Verildi'
WHEN LGMAIN.CURRSTAT = 5 THEN 'Tahsile Verildi(Protestolu)' WHEN LGMAIN.CURRSTAT = 6 THEN 'İade Edildi' WHEN LGMAIN.CURRSTAT = 7 THEN 'Protesto Edildi' WHEN LGMAIN.CURRSTAT = 8 THEN 'Tahsil Edildi'
WHEN LGMAIN.CURRSTAT = 9 THEN 'Verilen Çek' when LGMAIN.CURRSTAT = 9 then 'Borç Senedimiz' WHEN LGMAIN.CURRSTAT = 10 THEN 'Borç Senedimiz' WHEN LGMAIN.CURRSTAT = 11 THEN 'Karşılığı Yok' WHEN LGMAIN.CURRSTAT =
12 THEN 'Tahsil Edilemiyor' WHEN LGMAIN.CURRSTAT = 14 THEN 'Portföyde Protestolu' END AS DURUM,
CASE WHEN LGMAIN.DOC = 3 THEN 'Kendi Çekimiz' WHEN LGMAIN.DOC = 2 THEN 'Müşteri Seneti' WHEN LGMAIN.DOC = 4 THEN 'Kendi Senedimiz' WHEN LGMAIN.DOC = 1 THEN 'Müşteri Çeki' END AS TUR,
BANKNAME AS [BANKA AÇIKLAMASI], BNBRANCHNO AS [ŞUBE KODU], BNACCOUNTNO AS [HESAP NO],
NEWSERINO AS SERINO, TRNET AS TUTAR,'DÖVİZ TÜRÜ'=CASE WHEN LGMAIN.TRCURR IN (0,160) THEN 'TL' WHEN LGMAIN.TRCURR=1 THEN 'USD' WHEN LGMAIN.TRCURR=20
THEN 'EUR' ELSE '' END,
[DEVİR] = CASE LGMAIN.DEVIR WHEN 0 THEN 'Hayir' ELSE 'Evet' END,
CASE WHEN LGMAIN.CURRSTAT = 1 THEN '' ELSE
(SELECT TOP 1 CASE WHEN CST.CARDMD = 5 THEN(SELECT CL.DEFINITION_
FROM LG_001_CLCARD CL
WHERE CST.CARDREF = CL.LOGICALREF) WHEN CST.CARDMD = 7 THEN
(SELECT BNK.DEFINITION_
FROM LG_001_BANKACC BNK
WHERE CST.CARDREF = BNK.LOGICALREF) END
FROM LG_001_05_CSTRANS CST
WHERE CST.CSREF = LGMAIN.LOGICALREF
ORDER BY CST.LOGICALREF DESC) END AS [VERİLEN (CARİ/BANKA)], CASE WHEN LGMAIN.CURRSTAT = 1 THEN '' ELSE
(SELECT TOP 1 CASE WHEN CST.CARDMD = 5 THEN
(SELECT CL.CODE
FROM LG_001_CLCARD CL
WHERE CST.CARDREF = CL.LOGICALREF) WHEN CST.CARDMD = 7 THEN
(SELECT BNK.CODE
FROM LG_001_BANKACC BNK
WHERE CST.CARDREF = BNK.LOGICALREF) END
FROM LG_001_05_CSTRANS CST
WHERE CST.CSREF = LGMAIN.LOGICALREF
ORDER BY CST.LOGICALREF DESC) END AS [VERİLEN (CARİ/BANKA) KODU]
FROM LG_001_05_CSCARD AS LGMAIN
ORDER BY DUEDATE ASC
Kaynak: https://excelturkey.com/konu/portfoydeki-cek-durumunda-ciro-eden-bilgisi.729/ Emek için teşekkürler...
Tablodaki bazı alanları temizledim. Biraz daha revize edilmeyi bekliyor....
0 notes
Note
adelia!! have a lovely day/night!!
send me a name and i’ll make a mini playlist from the songs i have on my playlists!
artificial heart - jonathan coulton
dirty laundry - all time low
elephant - tame impala
live like a warrior - matisyahu
i wanna be setdated - ramones
addicted to you - scorpio loon
here’s the link to the playlist!
3 notes
·
View notes
Text
Bath Bombs for Kids with Toys Inside for Girls Boys - 12 Surprise Gift Set, Bubble Bath Fizzies Vegan Essential Oil Spa Fizz Balls Christmas Gift Kit
Bath Bombs for Kids with Toys Inside for Girls Boys – 12 Surprise Gift Set, Bubble Bath Fizzies Vegan Essential Oil Spa Fizz Balls Christmas Gift Kit
Price: (as of – Details) 12 Bath Bombs Set for Kids with Surprise Toys insideIs Discontinued By Manufacturer:NoPackage Dimensions:8.74 x 6.46 x 2.32 inches; 2.16 PoundsItem model number:Bath Bombs 14 SetDate First Available:September 9, 2018Manufacturer:ExcallaASIN:B07H792PNJ 100% SAFE for KIDS: These bath balls made from organic ingredient and contain no artificial flavors or colors…

View On WordPress
0 notes
Text
if mm is between 1 and 12, sets month to mm
if mm is between 1 and 12, sets month to mm
public class Date { private int month; private int day; private int year; /** default constructor * sets month to 1, day to 1 and year to 2000 */ public Date( ) { setDate( 1, 1, 2000 ); } /** overloaded constructor * @param mm initial value for month * @param dd initial value for day * @param yyyy initial value for year * * passes parameters to setDate method */ public Date( int mm, int dd, int…
View On WordPress
0 notes
Photo
API Authentication With Node.js
Building APIs is important; however, building secured APIs is also very important. In this tutorial, you learn how to build a secured API in Node.js. The authentication will be handled using tokens. Let's dive in.
Cookies vs. Tokens
Let's talk a little about cookies and tokens, to understand how they work and the differences between them.
Cookie-based authentication keeps an authentication record or session both on the server and the client side. In other words, it is stateful. The server keeps track of an active session in the database, while a cookie is created on the front-end to hold a session identifier.
In token-based authentication, every server request is accompanied by a token which is used by the server to verify the authenticity of the request. The server does not keep a record of which users are logged in. Token-based authentication is stateless.
In this tutorial, you will implement token-based authentication.
Setting Up an Express App
First, create a folder where you will be working from, and initialize npm. You can do so by running:
npm init -y
Use the package.json file I have below. It contains all the dependencies you will be making use of to build this application.
#package.json { "name": "api-auth", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "start-dev": "nodemon app.js", "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { "bcryptjs": "^2.4.3", "body-parser": "^1.17.2", "express": "^4.15.4", "express-promise-router": "^2.0.0", "joi": "^10.6.0", "jsonwebtoken": "^8.0.0", "mongoose": "^4.11.10", "morgan": "^1.8.2", "nodemon": "^1.12.0", "passport": "^0.4.0", "passport-jwt": "^3.0.0", "passport-local": "^1.0.0" } }
Now you can install the dependencies by running:
npm install
You can go grab a cup of coffee as npm does its magic; you'll need it for this ride!
Create a new file called app.js. In this file, you will require some packages and do a bit of setup. Here is how it should look.
#app.js // 1 const express = require('express') const morgan = require('morgan') const bodyParser = require('body-parser') const mongoose = require('mongoose') const routes = require('./routes/users') // 2 mongoose.Promise = global.Promise mongoose.connect('mongodb://localhost:27017/api-auth') const app = express() // 3 app.use(morgan('dev')) app.use(bodyParser.json()) // 4 app.use('/users', routes) // 5 const port = process.env.PORT || 3000 app.listen(port) console.log(`Server listening at ${port}`)
This imports all dependencies you installed using NPM. Here you are requiring express, morgan, body-parser, and mongoose. Morgan is an HTTP logger for Node.js. Here, morgan will be used to log HTTP requests to your console. So you see something like this when requests are made: POST /users/signin 401 183.635 ms - -. You also require your routes (which will be created soon) and set it to routes.
Here you are setting mongoose to make use of ES6 promises.
Set up morgan and body-parser middleware. Body-parser makes incoming requests available in your req.body property.
Set up routes. With this, whenever a request is made to /users, the routes file which you required above and set to routes will be used.
You set port to the port of your environment or 3000 and then pass it to the listen function which is called on the app to start up your server. When the server starts, a log is sent to the console to show that the server has started.
It's time to get our model up and running.
Map Out the User Model
Your User model will do a few things:
Create a user schema.
Hash the user password.
Validate the password.
Time to see what that should look like in real code. Create a folder called models, and in the folder create a new file called user.js. The first thing you want to do is require the dependencies you will be making use of.
The dependencies you will need here include mongoose and bcryptjs.
You will need bcryptjs for the hashing of a user password. We will come to that, but for now just require the dependencies like so.
#models/user.js const mongoose = require('mongoose') const bcrypt = require('bcryptjs')
With that out of the way, you want to create your user schema. This is where mongoose comes in handy. Your schema will map to a MongoDB collection, defining how each document within the collection should be shaped. Here is how the schema for your current model should be structured.
#models/user.js ... const userSchema = new mongoose.Schema({ email: { type: String, required: true, unique: true, lowercase: true }, password: { type: String, required: true } })
In the above, you have just two fields: email and password. You are making both fields a type of String, and requiring them. The email also has an option of unique, as you will not want to different users signing up with the same email, and it is also important that the email is in lowercase.
The next part of your model will handle the hashing of the user password.
#models/user.js ... userSchema.pre('save', async function (next) { try { const salt = await bcrypt.genSalt(10) const passwordhash = await bcrypt.hash(this.password, salt) this.password = passwordhash next() } catch (error) { next(error) } })
The code above makes of bcryptjs to generate a salt. You also use bcryptjs to hash the user password by passing in the user's password and the salt you just generated. The newly hashed password gets stored as the password for the user. The pre hook function ensures this happens before a new record of the user is saved to the database. When the password has been successfully hashed, control is handed to the next middleware using the next() function, else an error is thrown.
Finally, you need to validate user password. This comes in handy when a user wants to sign in, unlike the above which happens for signing up.
In this part, you need to ensure a user who wants to sign in is rightly authenticated. So you create an instance method called isValidPassword(). In this method, you pass in the password the user entered and compare it with the password attributed to that user. The user is found using the email address s/he entered; you will see how this is handled soon. A new error is thrown if one is encountered.
#models/user.js ... userSchema.methods.isValidPassword = async function (newPassword) { try { return await bcrypt.compare(newPassword, this.password) } catch (error) { throw new Error(error) } } module.exports = mongoose.model('User', userSchema)
When that is all set and done, it is important you export the file as a module so it can be rightly required.
Up and Running With Passport
Passport provides a simple way to authenticate requests in Node.js. These requests go through what are called strategies. In this tutorial, you will implement two strategies.
Go ahead and create a file called passport.js in your working directory. Here is what mine looks like.
#passport.js // 1 const passport = require('passport') const JwtStrategy = require('passport-jwt').Strategy const { ExtractJwt } = require('passport-jwt') const LocalStrategy = require('passport-local').Strategy const { JWT_SECRET } = require('./config/index') const User = require('./models/user') // 2 passport.use(new JwtStrategy({ jwtFromRequest: ExtractJwt.fromHeader('authorization'), secretOrKey: JWT_SECRET }, async (payload, done) => { try { const user = User.findById(payload.sub) if (!user) { return done(null, false) } done(null, user) } catch(err) { done(err, false) } })) // 3 passport.use(new LocalStrategy({ usernameField: 'email' }, async (email, password, done) => { try { const user = await User.findOne({ email }) if (!user) { return done(null, false) } const isMatch = await user.isValidPassword(password) if (!isMatch) { return done(null, false) } done(null, user) } catch (error) { done(error, false) } }))
Require dependencies installed using NPM.
Creates a new instance of JwtStrategy. This object receives two important arguments: secretOrKey and jwtFromRequest. The secretOrKey will be the JWT secret key which you will create shortly. jwtFromRequest defines the token that will be sent in the request. In the above, the token will be extracted from the header of the request. Next, you do a validation to look for the right user, and an error gets thrown if the user is not found.
Create a new instance of LocalStrategy. By default, the LocalStrategy uses only the username and password parameters. Since you are making use of email, you have to set the usernameField to email. You use the email to find the user, and when the user is found, the isValidPassword() function which you created in the user model gets called. This method compares the password entered with the one stored in the database. The comparison is done using the bcryptjs compared method. Errors are thrown if any is encountered, else the user is returned.
Before you jump to setting your controllers and routes, you need to create the JWT secret key mentioned above. Create a new folder called config, and a file inside called index.js. You can make the file look like this.
#config/index.js module.exports = { JWT_SECRET: 'apiauthentication' }
User Controllers
The user controller gets called whenever a request is made to your routes. Here is how it should look.
#controllers/users.js // 1 const JWT = require('jsonwebtoken') const User = require('../models/user') const { JWT_SECRET } = require('../config/index') // 2 signToken = ((user) => { return JWT.sign({ iss: 'ApiAuth', sub: user.id, iat: new Date().getTime(), exp: new Date().setDate(new Date().getDate() + 1) }, JWT_SECRET) }) module.exports = { // 3 signup: async (req, res, next) => { console.log('UsersController.signup() called') const { email, password } = req.value.body const foundUser = await User.findOne({ email }) if (foundUser) { return res.status(403).json({ error: 'Email is already in use' }) } const newUser = new User({ email, password }) await newUser.save() const token = signToken(newUser) res.status(200).json({ token }) }, // 4 signin: async (req, res, next) => { const token = signToken(req.user) res.status(200).json({ token }) }, // 5 secret: async (req, res, next) => { res.json({ secret: "resource" }); } }
Require dependencies.
Here you are creating a new token for the user. To create the token, you need to create the payload, which contains the claims. Here you set the issuer, subject, expiration, and issued at. The creation of this token is saved in a function called signToken().
This is the sign-up action that gets called when creating a new user. The email and password are obtained from the body of the request. You need to check if a user with the same email exists, to ensure two users are not signed up with same email address. When that has been verified, the signToken() function gets called with the new user as an argument to create a new token.
This action handles the signing in of users. Here you simply pass in the user who is trying to sign in to the signToken() function that creates a new token.
You are using this function for a secret route that can only be accessed by users who have been authenticated.
Setting Up Routes
Before you create the main routes for your application, you will first create a route helper. Go ahead and create a new folder called helpers, and a file called routeHelpers.js. Here is how it should look.
#helpers/routeHelpers.js const Joi = require('joi') module.exports = { validateBody: (schema) => { return (req, res, next) => { const result = Joi.validate(req.body, schema) if (result.error) { return res.status(400).json(result.error) } if (!req.value) { req.value = {} } req.value['body'] = result.value next() } }, schemas: { authSchema: Joi.object().keys({ email: Joi.string().email().required(), password: Joi.string().required() }) } }
Here you are validating the body of requests sent by users. This will ensure that users enter the right details when signing up or in. The details to be validated are obtained from req.body.
The routes of your application will take this format.
#routes/users.js const express = require('express') const router = require('express-promise-router')() const passport = require('passport') const passportConf = require('../passport') const { validateBody, schemas } = require('../helpers/routeHelpers') const UsersController = require('../controllers/users') router.route('/signup') .post(validateBody(schemas.authSchema), UsersController.signup) router.route('/signin') .post(validateBody(schemas.authSchema), passport.authenticate('local', { session: false }), UsersController.signin) router.route('/secret') .get(passport.authenticate('jwt', { session: false }), UsersController.secret) module.exports = router
Save it in routes/users.js. In the above, you are authenticating each request, and then calling the respective controller action.
Now you can start up your server by running:
npm run start-dev
Open up postman and play around with your newly created API.
Conclusion
You can go further to integrate new features to the API. A simple Book API with CRUD actions with routes that need to be authenticated will do. In the tutorial, you learned how to build a fully fledged authenticated API.
If you’re looking for additional JavaScript resources to study or to use in your work, check out what we have available in the Envato marketplace.
by Chinedu Izuchukwu via Envato Tuts+ Code http://ift.tt/2xk3siq
6 notes
·
View notes